Project

General

Profile

SipMiddlewareApi » History » Version 160

Tijmen de Mes, 04/19/2012 04:06 PM

1 147 Adrian Georgescu
h1. Middleware API
2 102 Adrian Georgescu
3 1 Adrian Georgescu
4
5
6 147 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 [[SipConfigurationAPI|Configuration API]].
7 1 Adrian Georgescu
8 152 Tijmen de Mes
!={width:500px}sipsimple-middleware.png!
9 147 Adrian Georgescu
10
11
h2. SIPApplication
12
13
14 62 Luci Stanescu
Implemented in [browser:sipsimple/application.py]
15 1 Adrian Georgescu
16
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:
17 147 Adrian Georgescu
* the twisted thread
18
* the configuration system, via the [[SipConfigurationAPI#ConfigurationManager|ConfigurationManager]]
19
* the core [[SipCoreApiDocumentation#Engine|Engine]] using the settings in the configuration
20
* the [[SipMiddlewareApi#AccountManager|AccountManager]], using the accounts in the configuration
21
* the [[SipMiddlewareApi#SessionManager|SessionManager]], in order to handle incoming sessions
22
* two [[SipMiddlewareApi#AudioBridge|AudioBridges]], using the settings in the configuration
23 1 Adrian Georgescu
24
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.
25
26
27 147 Adrian Georgescu
h4. methods 
28 1 Adrian Georgescu
29 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
30
>Instantiates a new SIPApplication.
31 1 Adrian Georgescu
32 147 Adrian Georgescu
*start*(_self_, *storage*)
33
>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.
34 1 Adrian Georgescu
35 147 Adrian Georgescu
*stop*(_self_)
36
>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.
37 1 Adrian Georgescu
38
39 147 Adrian Georgescu
h4. attributes
40 1 Adrian Georgescu
41 147 Adrian Georgescu
*running*
42 154 Tijmen de Mes
>@True@ if the SIPApplication is running (it has been started and it has not been told to stop), @False@ otherwise.
43 1 Adrian Georgescu
44 147 Adrian Georgescu
*storage*
45
>Holds an object which implements the @ISIPSimpleStorage@ interface which will be used to provide a storage facility to other middleware components.
46 1 Adrian Georgescu
47 147 Adrian Georgescu
*local_nat_type*
48
>String containing the detected local NAT type.
49 1 Adrian Georgescu
50 147 Adrian Georgescu
*alert_audio_mixer*
51
>The @AudioMixer@ object created on the alert audio device as defined by the configuration (by SIPSimpleSettings.audio.alert_device).
52 1 Adrian Georgescu
53 147 Adrian Georgescu
*alert_audio_bridge*
54
>An @AudioBridge@ where @IAudioPort@ objects can be added to playback sound to the alert device.
55 1 Adrian Georgescu
56 147 Adrian Georgescu
*alert_audio_device*
57
>An @AudioDevice@ which corresponds to the alert device as defined by the configuration. This will always be part of the alert_audio_bridge.
58 1 Adrian Georgescu
59 147 Adrian Georgescu
*voice_audio_mixer*
60
>The @AudioMixer@ object created on the voice audio device as defined by the configuration (by SIPSimpleSettings.audio.input_device and SIPSimpleSettings.audio.output_device).
61 1 Adrian Georgescu
62 147 Adrian Georgescu
*voice_audio_bridge*
63
>An @AudioBridge@ where @IAudioPort@ objects can be added to playback sound to the output device or record sound from the input device.
64 1 Adrian Georgescu
65 147 Adrian Georgescu
*voice_audio_device*
66
>An @AudioDevice@ which corresponds to the voice device as defined by the configuration. This will always be part of the voice_audio_bridge.
67 1 Adrian Georgescu
68
69 147 Adrian Georgescu
h4. notifications 
70 1 Adrian Georgescu
71
72
73
*SIPApplicationWillStart*
74 147 Adrian Georgescu
>This notification is sent just after the configuration has been loaded and the twisted thread started, but before any other components have been initialized.
75 158 Tijmen de Mes
76 153 Tijmen de Mes
>+_timestamp_+:
77 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
78 147 Adrian Georgescu
79 1 Adrian Georgescu
*SIPApplicationDidStart*
80 147 Adrian Georgescu
>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.
81 158 Tijmen de Mes
82 153 Tijmen de Mes
>+_timestamp_+:
83 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
84 1 Adrian Georgescu
85 147 Adrian Georgescu
*SIPApplicationWillEnd*
86 1 Adrian Georgescu
>This notification is sent as soon as the @stop()@ method has been called.
87 158 Tijmen de Mes
88 153 Tijmen de Mes
>+_timestamp_+:
89 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
90 1 Adrian Georgescu
91 147 Adrian Georgescu
*SIPApplicationDidEnd*
92
>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).
93 158 Tijmen de Mes
94 153 Tijmen de Mes
>+_timestamp_+:
95 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
96 147 Adrian Georgescu
97 1 Adrian Georgescu
*SIPApplicationFailedToStartTLS*
98 147 Adrian Georgescu
>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.
99 158 Tijmen de Mes
100 153 Tijmen de Mes
>+_timestamp_+:
101 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
102 158 Tijmen de Mes
103 153 Tijmen de Mes
>+_error_+:
104 157 Tijmen de Mes
>>The exception raised by the Engine which identifies the cause for not being able to start the TLS transport.
105 1 Adrian Georgescu
106
107
108 147 Adrian Georgescu
h2. Storage API
109
110
111
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.
112
113
114
h3. API Definition
115
116
117
The @Storage API@ currently requires the following attributes to be defined as per the @ISIPSimpleStorage@ interface:
118
119
*configuration_backend*
120
>The backend used for storing the configuration.
121
122
*xcap_storage_factory*
123
>Factory used to create XCAP storage backends for each account.
124
125
126
h3. Provided implementations
127
128
129
Two storage implementations are provided: *FileStorage* and *MemoryStorage* both located in the *sipsimple.storage* module.
130
131
132
h2. SIP Sessions
133
134
135
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.
136
137
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 [[SipMiddlewareApi#MediaStreamRegistry|MediaStreamRegistry]].
138
139
140
141
h3. SessionManager
142
143
144 1 Adrian Georgescu
Implemented in [browser:sipsimple/session.py]
145
146 147 Adrian Georgescu
The @sipsimple.session.SessionManager@ class is a singleton, which acts as the central aggregation point for sessions within the middleware.
147 1 Adrian Georgescu
Although it is mainly used internally, the application can use it to query information about all active sessions.
148
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.
149
150
151 147 Adrian Georgescu
h4. attributes
152 1 Adrian Georgescu
153
154
155 147 Adrian Georgescu
*sessions*
156
>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.
157 1 Adrian Georgescu
158
159 147 Adrian Georgescu
h4. methods
160 1 Adrian Georgescu
161
162
163 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
164
>Instantiate a new @SessionManager@ object.
165 1 Adrian Georgescu
166 147 Adrian Georgescu
167
*start*(_self_)
168
>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.
169
170
*stop*(_self_)
171
>End all connected sessions. This method is called automatically when SIPApplication is stopped. The application should not call this method directly.
172
173
174
h3. Session
175
176
177 1 Adrian Georgescu
Implemented in [browser:sipsimple/session.py]
178
179 147 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.
180 1 Adrian Georgescu
181 155 Tijmen de Mes
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. State changes are triggered by methods called on the object by the application or by received network events. These states and their transitions are represented in the following diagram:
182 1 Adrian Georgescu
183 156 Tijmen de Mes
!sipsimple-core-invite-state-machine-2.png!
184 1 Adrian Georgescu
185 147 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.
186 1 Adrian Georgescu
187 147 Adrian Georgescu
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.
188 1 Adrian Georgescu
189
190 147 Adrian Georgescu
h4. methods
191 1 Adrian Georgescu
192
193
194 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *account*)
195
>Creates a new @Session@ object in the @None@ state.
196 158 Tijmen de Mes
197 1 Adrian Georgescu
>+_account_+:
198 157 Tijmen de Mes
>>The local account to be associated with this @Session@.
199 1 Adrian Georgescu
200 147 Adrian Georgescu
*connect*(_self_, *to_header*, *routes*, *streams*, *is_focus*=@False@, *subject*=@None@)
201
>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.
202
>Before contacting the remote party, a @SIPSessionNewOutgoing@ notification will be emitted.
203
>If there is a failure or the remote party rejected the offer, a @SIPSessionDidFail@ notification will be sent.
204
>Any time a ringing indication is received from the remote party, a @SIPSessionGotRingIndication@ notification is sent.
205
>If the remote party accepted the session, a @SIPSessionWillStart@ notification will be sent, followed by a @SIPSessionDidStart@ notification when the session is actually established.
206
>This method may only be called while in the @None@ state.
207 158 Tijmen de Mes
208 1 Adrian Georgescu
>+_to_header_+:
209 157 Tijmen de Mes
>>A @sipsimple.core.ToHeader@ object representing the remote identity to initiate the session to.
210 158 Tijmen de Mes
211 147 Adrian Georgescu
>+_routes_+:
212 157 Tijmen de Mes
>>An iterable of @sipsimple.util.Route@ objects, specifying the IP, port and transport to the outbound proxy.
213
>>These routes will be tried in order, until one of them succeeds.
214 158 Tijmen de Mes
215 147 Adrian Georgescu
>+_streams_+:
216 157 Tijmen de Mes
>>A list of stream objects which will be offered to the remote endpoint.
217 158 Tijmen de Mes
218 147 Adrian Georgescu
>+_is_focus_+:
219 1 Adrian Georgescu
>>Boolean flag indicating if the @isfocus@ parameter should be added to the @Contact@ header according to RFC 4579.
220 158 Tijmen de Mes
221 147 Adrian Georgescu
>+_subject_+:
222
>>Session subject. If not None a @Subject@ header will be added with the specified value.
223 158 Tijmen de Mes
224 1 Adrian Georgescu
*send_ring_indication*(_self_)
225 147 Adrian Georgescu
>Sends a 180 provisional response in the case of an incoming session.
226
227
*accept*(_self_, *streams*)
228
>Calling this methods will accept an incoming session and move the state machine to the @accepting@ state.
229
>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.
230 1 Adrian Georgescu
>After this method is called, @SIPSessionWillStart@ followed by @SIPSessionDidStart@ will be emitted, or @SIPSessionDidFail@ on an error.
231 147 Adrian Georgescu
>This method may only be called while in the @incoming@ state.
232
  
233
>+_streams_+:
234 158 Tijmen de Mes
>>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.
235 147 Adrian Georgescu
236
*reject*(_self_, *code*=@603@, *reason*=@None@)
237
>Reject an incoming session and move it to the @terminating@ state, which eventually leads to the @terminated@ state.
238 1 Adrian Georgescu
>Calling this method will cause the @Session@ object to emit a @SIPSessionDidFail@ notification once the session has been rejected.
239 147 Adrian Georgescu
>This method may only be called while in the @incoming@ state.
240
  
241 1 Adrian Georgescu
>+_code_+:
242 158 Tijmen de Mes
>>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).
243 147 Adrian Georgescu
  
244
>+_reason_+:
245 158 Tijmen de Mes
>>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.
246 147 Adrian Georgescu
247 1 Adrian Georgescu
*accept_proposal*(_self_, *streams*)
248
>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.
249 147 Adrian Georgescu
>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.
250 1 Adrian Georgescu
>This method may only be called while in the @received_proposal@ state.
251
  
252 147 Adrian Georgescu
>+_streams_+:
253 158 Tijmen de Mes
>>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.
254 147 Adrian Georgescu
255
*reject_proposal*(_self_, *code*=@488@, *reason*=@None@)
256
>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.
257
>This method may only be called while in the @received_proposal@ state.
258 1 Adrian Georgescu
  
259 147 Adrian Georgescu
>+_code_+:
260 158 Tijmen de Mes
>>An integer which represents the SIP status code in the response which is to be sent. Usually, this is 488 (Not Acceptable Here).
261 147 Adrian Georgescu
  
262 1 Adrian Georgescu
>+_reason_+:
263 158 Tijmen de Mes
>>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.
264 1 Adrian Georgescu
265 147 Adrian Georgescu
*add_stream*(_self_, *stream*)
266
>Proposes a new stream to the remote party.
267
>Calling this method will cause a @SIPSessionGotProposal@ notification to be emitted.
268
>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.
269
>This method may only be called while in the @connected@ state.
270 1 Adrian Georgescu
271 147 Adrian Georgescu
*remove_stream*(_self_, *stream*)
272
>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).
273
>This method may only be called while in the @connected@ state.
274 1 Adrian Georgescu
275 147 Adrian Georgescu
*cancel_proposal*(_self_)
276
>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.
277 1 Adrian Georgescu
278 147 Adrian Georgescu
*hold*(_self_)
279
>Put the streams of the session which support the notion of hold on hold.
280
>This will cause a @SIPSessionDidChangeHoldState@ notification to be sent.
281
>This method may be called in any state and will send the re-INVITE as soon as it is possible.
282 1 Adrian Georgescu
283 147 Adrian Georgescu
*unhold*(_self_)
284
>Take the streams of the session which support the notion of hold out of hold.
285
>This will cause a @SIPSessionDidChangeHoldState@ notification to be sent.
286
>This method may be called in any state and will send teh re-INVITE as soon as it is possible.
287 1 Adrian Georgescu
288 147 Adrian Georgescu
*end*(_self_)
289
>This method may be called any time after the @Session@ has started in order to terminate the session by sending a BYE request.
290
>Right before termination a @SIPSessionWillEnd@ notification is sent, after termination @SIPSessionDidEnd@ is sent.
291 1 Adrian Georgescu
292 147 Adrian Georgescu
*transfer*(_self_, *target_uri*,  *replaced_session*=@None@)
293
>Proposes a blind call transfer to a new target URI or assisted transfer to an URI belonging to an already established session. 
294 1 Adrian Georgescu
295 147 Adrian Georgescu
*accept_transfer*(_self_)
296
>Accepts an incoming call transfer request.
297 1 Adrian Georgescu
298 147 Adrian Georgescu
*reject_transfer*(_self_, *code*=@486@, *reason_=@None@)
299
>Rejects an incoming call transfer request.
300 1 Adrian Georgescu
301
302
303 147 Adrian Georgescu
h4. attributes
304 1 Adrian Georgescu
305
306
307 147 Adrian Georgescu
*state*
308
>The state the object is currently in, being one of the states from the diagram above.
309 1 Adrian Georgescu
310 147 Adrian Georgescu
*account*
311
>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ object that the @Session@ is associated with.
312
>On an outbound session, this is the account the application specified on object instantiation.
313 1 Adrian Georgescu
314 147 Adrian Georgescu
*direction*
315
>A string indicating the direction of the initial negotiation of the session.
316
>This can be either @None@, "incoming" or "outgoing".
317 1 Adrian Georgescu
318 147 Adrian Georgescu
*transport*
319
>A string representing the transport this @Session@ is using: @"udp"@, @"tcp"@ or @"tls"@.
320 1 Adrian Georgescu
321 147 Adrian Georgescu
*start_time*
322
>The time the session started as a @datetime.datetime@ object, or @None@ if the session was not yet started.
323 1 Adrian Georgescu
324 147 Adrian Georgescu
*stop_time*
325
>The time the session stopped as a @datetime.datetime@ object, or @None@ if the session has not yet terminated.
326 1 Adrian Georgescu
327 147 Adrian Georgescu
*on_hold*
328
>Boolean indicating whether the session was put on hold, either by the local or the remote party.
329 1 Adrian Georgescu
330 147 Adrian Georgescu
*remote_user_agent*
331
>A string indicating the remote user agent, if it provided one.
332
>Initially this will be @None@, it will be set as soon as this information is received from the remote party (which may be never).
333 1 Adrian Georgescu
334 147 Adrian Georgescu
*local_identity*
335
>The @sipsimple.core.FrozenFromHeader@ or @sipsimple.core.FrozenToHeader@ identifying the local party, if the session is active, @None@ otherwise.
336 1 Adrian Georgescu
337 147 Adrian Georgescu
*remote_identity*
338
>The @sipsimple.core.FrozenFromHeader@ or @sipsimple.core.FrozenToHeader@ identifying the remote party, if the session is active, @None@ otherwise.
339 1 Adrian Georgescu
340 147 Adrian Georgescu
*streams*
341
>A list of the currently active streams in the @Session@.
342 1 Adrian Georgescu
343 147 Adrian Georgescu
*proposed_streams*
344
>A list of the currently proposed streams in the @Session@, or @None@ if there is no proposal in progress.
345 1 Adrian Georgescu
346 147 Adrian Georgescu
*conference*
347
>A @ConferenceHandler@ object instance (or Null). It can be later used to add/remove participants from a remote conference.
348 1 Adrian Georgescu
349 147 Adrian Georgescu
*subject*
350
>The session subject as a unicode object.
351 1 Adrian Georgescu
352
*replaced_session*
353 147 Adrian Georgescu
>A @Session@ object instance (or Null). It can be used for assisted call transfer.
354
355
*transfer_handler*
356 1 Adrian Georgescu
>A @TransferHandler@ object instance (or Null). It is used for managing the call transfer process.
357
358
*transfer_info*
359
>A @TransferInfo@ object instance (or Null). It is used for describing the details of a call transfer operation.
360
361
362
h4. notifications
363 147 Adrian Georgescu
364
365 1 Adrian Georgescu
366 147 Adrian Georgescu
*SIPSessionNewIncoming*
367
>Will be sent when a new incoming @Session@ is received.
368
>The application should listen for this notification to get informed of incoming sessions.
369 1 Adrian Georgescu
  
370 55 Adrian Georgescu
>+_timestamp_+:
371 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
372 147 Adrian Georgescu
  
373
>+_streams_+:
374 158 Tijmen de Mes
>>A list of streams that were proposed by the remote party.
375 147 Adrian Georgescu
376
*SIPSessionNewOutgoing*
377
>Will be sent when the application requests a new outgoing @Session@.
378 1 Adrian Georgescu
  
379 147 Adrian Georgescu
>+_timestamp_+:
380 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
381 147 Adrian Georgescu
  
382
>+_streams_+:
383 158 Tijmen de Mes
>>A list of streams that were proposed to the remote party.
384 147 Adrian Georgescu
385 67 Luci Stanescu
*SIPSessionGotRingIndication*
386 147 Adrian Georgescu
>Will be sent when an outgoing @Session@ receives an indication that a remote device is ringing.
387 94 Adrian Georgescu
  
388 147 Adrian Georgescu
>+_timestamp_+:
389 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
390 147 Adrian Georgescu
391
*SIPSessionGotProvisionalResponse*
392 67 Luci Stanescu
>Will be sent whenever the @Session@ receives a provisional response as a result of sending a (re-)INVITE.
393 147 Adrian Georgescu
  
394
>+_timestamp_+:
395 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
396 1 Adrian Georgescu
  
397 147 Adrian Georgescu
>+_code_+:
398 158 Tijmen de Mes
>>The SIP status code received.
399 147 Adrian Georgescu
  
400 94 Adrian Georgescu
>+_reason_+:
401 158 Tijmen de Mes
>>The SIP status reason received.
402 1 Adrian Georgescu
403 147 Adrian Georgescu
*SIPSessionWillStart*
404
>Will be sent just before a @Session@ completes negotiation.
405
>In terms of SIP, this is sent after the final response to the @INVITE@, but before the @ACK@.
406
  
407
>+_timestamp_+:
408 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
409 1 Adrian Georgescu
410 147 Adrian Georgescu
*SIPSessionDidStart*
411
>Will be sent when a @Session@ completes negotiation and all the streams have started.
412
>In terms of SIP this is sent after the @ACK@ was sent or received.
413 1 Adrian Georgescu
  
414
>+_timestamp_+:
415 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
416 147 Adrian Georgescu
  
417 1 Adrian Georgescu
>+_streams_+:
418 159 Tijmen de Mes
>>The list of streams which now form the active streams of the @Session@.
419 1 Adrian Georgescu
420
*SIPSessionDidFail*
421 147 Adrian Georgescu
>This notification is sent whenever the session fails before it starts.
422
>The failure reason is included in the data attributes.
423
>This notification is never followed by @SIPSessionDidEnd@.
424 1 Adrian Georgescu
  
425
>+_timestamp_+:
426 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
427 147 Adrian Georgescu
  
428
>+_originator_+:
429 159 Tijmen de Mes
>>A string indicating the originator of the @Session@. This will either be "local" or "remote".
430 1 Adrian Georgescu
  
431 147 Adrian Georgescu
>+_code_+:
432 159 Tijmen de Mes
>>The SIP error code of the failure.
433 147 Adrian Georgescu
  
434 1 Adrian Georgescu
>+_reason_+:
435 159 Tijmen de Mes
>>A SIP status reason.
436 147 Adrian Georgescu
  
437
>+_failure_reason_+:
438 159 Tijmen de Mes
>>A string which represents the reason for the failure, such as @"user_request"@, @"missing ACK"@, @"SIP core error..."@.
439 1 Adrian Georgescu
440 147 Adrian Georgescu
*SIPSessionWillEnd*
441
>Will be sent just before terminating a @Session@.
442 1 Adrian Georgescu
  
443
>+_timestamp_+:
444 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
445 147 Adrian Georgescu
446
*SIPSessionDidEnd*
447 1 Adrian Georgescu
>Will be sent always when a @Session@ ends as a result of remote or local session termination.
448 147 Adrian Georgescu
  
449
>+_timestamp_+:
450 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
451 1 Adrian Georgescu
  
452
>+_originator_+:
453 159 Tijmen de Mes
>>A string indicating who originated the termination. This will either be "local" or "remote".
454 147 Adrian Georgescu
  
455
>+_end_reason_+:
456 159 Tijmen de Mes
>>A string representing the termination reason, such as @"user_request"@, @"SIP core error..."@.
457 1 Adrian Georgescu
458 147 Adrian Georgescu
*SIPSessionDidChangeHoldState*
459
>Will be sent when the session got put on hold or removed from hold, either by the local or the remote party.
460 1 Adrian Georgescu
  
461
>+_timestamp_+:
462 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
463 147 Adrian Georgescu
  
464
>+_originator_+:
465 159 Tijmen de Mes
>>A string indicating who originated the hold request, and consequently in which direction the session got put on hold.
466 147 Adrian Georgescu
  
467
>+_on_hold_+:
468 159 Tijmen de Mes
>>@True@ if there is at least one stream which is on hold and @False@ otherwise.
469 1 Adrian Georgescu
  
470 147 Adrian Georgescu
>+_partial_+:
471 159 Tijmen de Mes
>>@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.
472 147 Adrian Georgescu
473
*SIPSessionGotProposal*
474 1 Adrian Georgescu
>Will be sent when either the local or the remote party proposes to add streams to the session.
475 147 Adrian Georgescu
  
476 1 Adrian Georgescu
>+_timestamp_+:
477 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
478 147 Adrian Georgescu
  
479
>+_originator_+:
480 159 Tijmen de Mes
>>The party that initiated the stream proposal, can be either "local" or "remote".
481 147 Adrian Georgescu
  
482
>+_streams_+:
483 159 Tijmen de Mes
>>A list of streams that were proposed.
484 147 Adrian Georgescu
485
*SIPSessionGotRejectProposal*
486
>Will be sent when either the local or the remote party rejects a proposal to have streams added to the session.
487 1 Adrian Georgescu
  
488 147 Adrian Georgescu
>+_timestamp_+:
489 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
490 147 Adrian Georgescu
  
491 1 Adrian Georgescu
>+_originator_+:
492 159 Tijmen de Mes
>>The party that initiated the stream proposal, can be either "local" or "remote".
493 147 Adrian Georgescu
  
494
>+_code_+:
495 159 Tijmen de Mes
>>The code with which the proposal was rejected.
496 147 Adrian Georgescu
  
497
>+_reason_+:
498 159 Tijmen de Mes
>>The reason for rejecting the stream proposal.
499 1 Adrian Georgescu
  
500 147 Adrian Georgescu
>+_streams_+:
501 159 Tijmen de Mes
>>The list of streams which were rejected.
502 147 Adrian Georgescu
503
*SIPSessionGotAcceptProposal*
504
>Will be sent when either the local or the remote party accepts a proposal to have stream( added to the session.
505
  
506 1 Adrian Georgescu
>+_timestamp_+:
507 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
508 147 Adrian Georgescu
  
509
>+_originator_+:
510 160 Tijmen de Mes
>>The party that initiated the stream proposal, can be either "local" or "remote".
511 1 Adrian Georgescu
  
512
>+_streams_+:
513 160 Tijmen de Mes
>>The list of streams which were accepted.
514 147 Adrian Georgescu
  
515
>+_proposed_streams_+:
516 160 Tijmen de Mes
>>The list of streams which were originally proposed.
517 147 Adrian Georgescu
518
*SIPSessionHadProposalFailure*
519
>Will be sent when a re-INVITE fails because of an internal reason (such as a stream not being able to start).
520 1 Adrian Georgescu
  
521 147 Adrian Georgescu
>+_timestamp_+:
522 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
523 147 Adrian Georgescu
  
524
>+_failure_reason_+:
525 160 Tijmen de Mes
>>The error which caused the proposal to fail.
526 1 Adrian Georgescu
  
527 147 Adrian Georgescu
>+_streams_+:
528 160 Tijmen de Mes
>>The streams which were part of this proposal.
529 147 Adrian Georgescu
530
*SIPSessionDidRenegotiateStreams*
531
>Will be sent when a media stream is either activated or deactivated.
532
>An application should listen to this notification in order to know when a media stream can be used.
533
  
534
>+_timestamp_+:
535 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
536 147 Adrian Georgescu
  
537
>+_action_+:
538 160 Tijmen de Mes
>>A string which is either @"add"@ or @"remove"@ which specifies what happened to the streams the notificaton referes to
539 1 Adrian Georgescu
  
540 147 Adrian Georgescu
>+_streams_+:
541 160 Tijmen de Mes
>>A list with the streams which were added or removed.
542 1 Adrian Georgescu
543 147 Adrian Georgescu
*SIPSessionDidProcessTransaction*
544
>Will be sent whenever a SIP transaction is complete in order to provide low-level details of the progress of the INVITE dialog.
545
  
546 160 Tijmen de Mes
>>+_timestamp_+:
547 1 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
548 147 Adrian Georgescu
  
549
>+_originator_+:
550 160 Tijmen de Mes
>>The initiator of the transaction, @"local"@ or @"remote"@.
551 147 Adrian Georgescu
  
552 1 Adrian Georgescu
>+_method_+:
553 160 Tijmen de Mes
>>The method of the request.
554 147 Adrian Georgescu
  
555
>+_code_+:
556 160 Tijmen de Mes
>>The SIP status code of the response.
557 1 Adrian Georgescu
  
558 147 Adrian Georgescu
>+_reason_+:
559 160 Tijmen de Mes
>>The SIP status reason of the response.
560 147 Adrian Georgescu
  
561
>+_ack_received_+:
562
563
>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.
564
565
*SIPSessionTransferNewOutgoing*
566 160 Tijmen de Mes
>>Will be sent whenever a SIP session initiates an outgoing call transfer request.
567 147 Adrian Georgescu
  
568
>+_timestamp_+:
569 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
570 147 Adrian Georgescu
  
571
>+_transfer_destination_+:
572 160 Tijmen de Mes
>>The destination SIP URI of the call transfer request.
573 147 Adrian Georgescu
  
574 1 Adrian Georgescu
>+_transfer_source_+:
575 160 Tijmen de Mes
>>The source SIP URI of the call transfer request.
576 147 Adrian Georgescu
577 1 Adrian Georgescu
*SIPSessionTransferDidStart*
578
>Will be sent whenever a call transfer has been started.
579 147 Adrian Georgescu
  
580
>+_timestamp_+:
581 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
582 147 Adrian Georgescu
583
*SIPSessionTransferDidFail*
584
>Will be sent whenever a call transfer request has failed.
585
  
586
>+_timestamp_+:
587 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
588 147 Adrian Georgescu
  
589
>+_code_+:
590 160 Tijmen de Mes
>>The SIP failure code reported by the SIP stack.
591 147 Adrian Georgescu
  
592
>+_reason_+:
593 160 Tijmen de Mes
>>The reason of the failure as a string.
594 147 Adrian Georgescu
595
596
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 [[SipSessionExample|Minimalist Session Example code]].
597
598
599
h3. IMediaStream
600
601
602
Implemented in [browser:sipsimple/streams/+init+.py]
603
604
This interface describes the API which the @Session@ uses to communicate with the streams. All streams used by the @Session@ +must+ respect this interface.
605
606
607
h4. methods
608
609
610
611
*<notextile>__init__</notextile>*(_self_, _account_)
612
>Initializes the generic stream instance.
613
614
*new_from_sdp*(_cls_, _account_, _remote_sdp_, _stream_index_)
615
>A classmethod which returns an instance of this stream implementation if the sdp is accepted by the stream or None otherwise.
616
  
617 160 Tijmen de Mes
>+_account_+:
618
>>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ object the session which this stream would be part of is associated with.
619 147 Adrian Georgescu
  
620 160 Tijmen de Mes
>+_remote_sdp_+:
621
>>The @FrozenSDPSession@ which was received by the remote offer.
622 147 Adrian Georgescu
  
623
stream_index:
624
625
>An integer representing the index within the list of media streams within the whole SDP which this stream would be instantiated for. 
626
627
*get_local_media*(_self_, _for_offer_)
628
>Return an @SDPMediaStream@ which represents an offer for using this stream if @for_offer@ is @True@ and a response to an SDP proposal otherwise.
629
  
630
for_offer:
631
632
  @True@ if the @SDPMediaStream@ will be used for an SDP proposal and @False@ if for a response.
633
634
*initialize*(_self_, _session_, _direction_)
635
>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.
636
  
637
session:
638
639
>The @Session@ object this stream will be part of.
640
  
641
direction:
642
643
  @"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.
644
645
*start*(_self_, _local_sdp_, _remote_sdp_, _stream_index_)
646
>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.
647
  
648
local_sdp:
649
650
>The @FrozenSDPSession@ which is used by the local endpoint.
651
  
652
remote_sdp:
653
654
>The @FrozenSDPSession@ which is used by the remote endpoint.
655
  
656
stream_index:
657
658
>An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
659
660
*validate_update*(_self_, _remote_sdp_, _stream_index_)
661
>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@. 
662
  
663
remote_sdp:
664
665
>The @FrozenSDPSession@ which is used by the remote endpoint.
666
  
667
stream_index:
668
669
>An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
670
671
*update*(_self_, _local_sdp_, _remote_sdp_, _stream_index_)
672
>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.
673
  
674
local_sdp:
675
676
>The @FrozenSDPSession@ which is used by the local endpoint.
677
  
678
remote_sdp:
679
680
>The @FrozenSDPSession@ which is used by the remote endpoint.
681
  
682
stream_index:
683
684
>An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
685
686
*hold*(_self_)
687
>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.
688
689
*unhold*(_self_)
690
>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.
691
692
*deactivate*(_self_)
693
>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.
694
695
*end*(_self_)
696
>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.
697
698
699
h4. attributes
700
701
702
703
*type* (class attribute)
704
>A string identifying the stream type (eg: @"audio"@, @"video"@).
705
706
*priority* (class attribute)
707
>An integer value indicating the stream priority relative to the other streams types (higher numbers have higher priority).
708
709
*hold_supported*
710
>True if the stream supports hold
711
712
*on_hold_by_local*
713
>True if the stream is on hold by the local party
714
715
*on_hold_by_remote*
716
>True if the stream is on hold by the remote
717
718
*on_hold*
719
>True if either on_hold_by_local or on_hold_by_remote is true
720
721
722
h4. notifications
723
724
725
These notifications must be generated by all streams in order for the @Session@ to know the state of the stream.
726
727
728
*MediaStreamDidInitialize*
729
>Sent when the stream has been successfully initialized.
730
731
*MediaStreamDidStart*
732
>Sent when the stream has been successfully started.
733
734
*MediaStreamDidFail*
735
>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).
736
737
*MediaStreamWillEnd*
738
>Sent immediately after the @end()@ method is called.
739
740
*MediaStreamDidEnd*
741
>Sent when the @end()@ method finished closing the stream.
742
743
744
h3. MediaStreamRegistry
745
746
747
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.
748
749
There are several pre-built streams based on the @IMediaStream@ API:
750
* @sipsimple.streams.rtp.AudioStream@ - Audio stream based on RTP
751
* @sipsimple.streams.msrp.ChatStream@ - Chat stream based on MSRP 
752
* @sipsimple.streams.msrp.FileTransferStream@ - File Transfer stream based on MSRP 
753
* @sipsimple.streams.msrp.DesktopSharingStream@ -  Desktop Sharing stream based on VNC over MSRP
754
755
Other streams which are created by the application must be registered in this registry. For a simple way of doing this, see [[SipMiddlewareApi#MediaStreamRegistrar|MediaStreamRegistrar]].
756
757
758
h4. methods
759
760
761
762
*<notextile>__init__</notextile>*(_self_)
763
>Instantiate the MediaStreamRegistry. This will be called just once when first (and only) instance is created.
764
765
*<notextile>__iter__</notextile>*(_self_)
766
>This method allows the registry to be iterated through and will return classes which were registered to it.
767
768
*add*(_self_, *cls*)
769
>Add @cls@ to the registry of streams. The class must implement the @IMediaStream@ interface.
770
771
772
h3. MediaStreamRegistrar
773
774
775
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.
776
777
<pre>
778 1 Adrian Georgescu
from zope.interface import implements
779
780
from sipsimple.streams import IMediaStream, MediaStreamRegistrar
781
782
783
class MyStream(object):
784
  __metaclass__ = MediaStreamRegistrar
785
786
  implements(IMediaStream)
787
  
788
[...] 
789 147 Adrian Georgescu
</pre>
790 1 Adrian Georgescu
791
792 147 Adrian Georgescu
h3. AudioStream
793
794
795 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/rtp.py]
796
797 147 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:
798 1 Adrian Georgescu
799 147 Adrian Georgescu
<pre>
800 1 Adrian Georgescu
Content-Type: application/sdp
801
Content-Length:  1093
802
803
v=0
804
o=- 3467525278 3467525278 IN IP4 192.168.1.6
805
s=blink-0.10.7-beta
806
c=IN IP4 80.101.96.20
807
t=0 0
808
m=audio 55328 RTP/AVP 104 103 102 3 9 0 8 101
809
a=rtcp:55329 IN IP4 80.101.96.20
810
a=rtpmap:104 speex/32000
811
a=rtpmap:103 speex/16000
812
a=rtpmap:102 speex/8000
813
a=rtpmap:3 GSM/8000
814
a=rtpmap:9 G722/8000
815
a=rtpmap:0 PCMU/8000
816
a=rtpmap:8 PCMA/8000
817
a=rtpmap:101 telephone-event/8000
818
a=fmtp:101 0-15
819
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:esI6DbLY1+Aceu0JNswN9Z10DcFx5cZwqJcu91jb
820
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:SHuEMm1BYJqOF4udKl73EaCwnsI57pO86bYKsg70
821
a=ice-ufrag:2701ed80
822
a=ice-pwd:6f8f8281
823
a=candidate:S 1 UDP 31 80.101.96.20 55328 typ srflx raddr 192.168.1.6 rport 55328
824
a=candidate:H 1 UDP 23 192.168.1.6 55328 typ host
825
a=candidate:H 1 UDP 23 10.211.55.2 55328 typ host
826
a=candidate:H 1 UDP 23 10.37.129.2 55328 typ host
827
a=candidate:S 2 UDP 30 80.101.96.20 55329 typ srflx raddr 192.168.1.6 rport 55329
828
a=candidate:H 2 UDP 22 192.168.1.6 55329 typ host
829
a=candidate:H 2 UDP 22 10.211.55.2 55329 typ host
830
a=candidate:H 2 UDP 22 10.37.129.2 55329 typ host
831
a=sendrecv
832 147 Adrian Georgescu
</pre>
833 1 Adrian Georgescu
834 147 Adrian Georgescu
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.
835 1 Adrian Georgescu
836
837 147 Adrian Georgescu
h4. methods
838 1 Adrian Georgescu
839
840
841 147 Adrian Georgescu
*start_recording*(_self_, *filename*=@None@)
842
>If an audio stream is present within this session, calling this method will record the audio to a @.wav@ file.
843
>Note that when the session is on hold, nothing will be recorded to the file.
844
>Right before starting the recording a @SIPSessionWillStartRecordingAudio@ notification will be emitted, followed by a @SIPSessionDidStartRecordingAudio@.
845
>This method may only be called while the stream is started.
846
  
847
>+_filename_+:
848 1 Adrian Georgescu
849 147 Adrian Georgescu
>The name of the @.wav@ file to record to.
850
>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.
851 1 Adrian Georgescu
852 147 Adrian Georgescu
*stop_recording*(_self_)
853
>This will stop a previously started recording.
854
>Before stopping, a @SIPSessionWillStopRecordingAudio@ notification will be sent, followed by a @SIPSessionDidStopRecordingAudio@.
855 1 Adrian Georgescu
856 147 Adrian Georgescu
*send_dtmf*(_self_, *digit*)
857
>If the audio stream is started, sends a DTMF digit to the remote party.
858
  
859
>+_digit_+:
860 1 Adrian Georgescu
861 147 Adrian Georgescu
>This should a string of length 1, containing a valid DTMF digit value (0-9, A-D, * or #).
862 1 Adrian Georgescu
863
864 147 Adrian Georgescu
h4. attributes
865 1 Adrian Georgescu
866
867
868 147 Adrian Georgescu
*sample_rate*
869
>If the audio stream was started, this attribute contains the sample rate of the audio negotiated.
870 1 Adrian Georgescu
871 147 Adrian Georgescu
*codec*
872
>If the audio stream was started, this attribute contains the name of the audio codec that was negotiated.
873 1 Adrian Georgescu
874 147 Adrian Georgescu
*srtp_active*
875
>If the audio stream was started, this boolean attribute indicates if SRTP is currently being used on the stream.
876 1 Adrian Georgescu
877 147 Adrian Georgescu
*ice_active*
878
  @True@ if the ICE candidates negotiated are being used, @False@ otherwise.
879 1 Adrian Georgescu
880 147 Adrian Georgescu
*local_rtp_address*
881
>If an audio stream is present within the session, this attribute contains the local IP address used for the audio stream.
882 1 Adrian Georgescu
883 147 Adrian Georgescu
*local_rtp_port*
884
>If an audio stream is present within the session, this attribute contains the local UDP port used for the audio stream.
885 1 Adrian Georgescu
886 147 Adrian Georgescu
*remote_rtp_address_sdp*
887
>If the audio stream was started, this attribute contains the IP address that the remote party gave to send audio to.
888 1 Adrian Georgescu
889 147 Adrian Georgescu
*remote_rtp_port_sdp*
890
>If the audio stream was started, this attribute contains the UDP port that the remote party gave to send audio to.
891 1 Adrian Georgescu
892 147 Adrian Georgescu
*remote_rtp_address_received*
893
>If the audio stream was started, this attribute contains the remote IP address from which the audio stream is being received.
894 1 Adrian Georgescu
895 147 Adrian Georgescu
*remote_rtp_port_received*
896
>If the audio stream was started, this attribute contains the remote UDP port from which the audio stream is being received.
897 1 Adrian Georgescu
898 147 Adrian Georgescu
*local_rtp_candidate_type*
899
>The local ICE candidate type which was selected by the ICE negotiation if it succeeded and @None@ otherwise.
900 1 Adrian Georgescu
901 147 Adrian Georgescu
*remote_rtp_candidate_type*
902
>The remote ICE candidate type which was selected by the ICE negotiation if it succeeded and @None@ otherwise.
903 1 Adrian Georgescu
904 147 Adrian Georgescu
*recording_filename*
905
>If the audio stream is currently being recorded to disk, this property contains the name of the @.wav@ file being recorded to.
906 1 Adrian Georgescu
907
908 147 Adrian Georgescu
h4. notifications
909 1 Adrian Georgescu
910
911
912 147 Adrian Georgescu
*AudioStreamDidChangeHoldState*
913
>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.
914
  
915
>+_timestamp_+:
916 1 Adrian Georgescu
917 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
918
  
919
originator:
920 1 Adrian Georgescu
921 147 Adrian Georgescu
>A string representing the party which requested the hold change, @"local"@ or @"remote"@
922
  
923
on_hold:
924 1 Adrian Georgescu
925 147 Adrian Georgescu
>A boolean indicating the new hold state from the point of view of the originator.
926 1 Adrian Georgescu
927 147 Adrian Georgescu
*AudioStreamWillStartRecordingAudio_
928
>Will be sent when the application requested that the audio stream be recorded to a @.wav@ file, just before recording starts.
929
  
930
>+_timestamp_+:
931
932
>A @datetime.datetime@ object indicating when the notification was sent.
933
  
934
>+_filename_+:
935
936
>The full path to the @.wav@ file being recorded to.
937
938
*AudioStreamDidStartRecordingAudio*
939
>Will be sent when the application requested that the audio stream be recorded to a @.wav@ file, just after recording started.
940
  
941
>+_timestamp_+:
942
943
>A @datetime.datetime@ object indicating when the notification was sent.
944
  
945
>+_filename_+:
946
947
>The full path to the @.wav@ file being recorded to.
948
949
*AudioStreamWillStopRecordingAudio*
950
>Will be sent when the application requested ending the recording to a @.wav@ file, just before recording stops.
951
  
952
>+_timestamp_+:
953
954
>A @datetime.datetime@ object indicating when the notification was sent.
955
  
956
>+_filename_+:
957
958
>The full path to the @.wav@ file being recorded to.
959
960
*AudioStreamDidStopRecordingAudio*
961
>Will be sent when the application requested ending the recording to a @.wav@ file, just after recording stoped.
962
  
963
>+_timestamp_+:
964
965
>A @datetime.datetime@ object indicating when the notification was sent.
966
  
967
>+_filename_+:
968
969
>The full path to the @.wav@ file being recorded to.
970
971
*AudioStreamDidChangeRTPParameters*
972
>This notification is sent when the RTP parameters are changed, such as codec, sample rate, RTP port etc.
973
  
974
>+_timestamp_+:
975
976
>A @datetime.datetime@ object indicating when the notification was sent.
977
978
*AudioStreamGotDTMF*
979
>Will be send if there is a DMTF digit received from the remote party on the audio stream. 
980
  
981
>+_timestamp_+:
982
983
>A @datetime.datetime@ object indicating when the notification was sent.
984
  
985
>+_digit_+:
986
987
>The DTMF digit that was received, in the form of a string of length 1.
988
989
*AudioStreamICENegotiationStateDidChange*
990
>This notification is proxied from the @RTPTransport@ and as such has the same data as the @RTPTransportICENegotiationStateDidChange@.
991
992
*AudioStreamICENegotiationDidSucceed*
993
>This notification is proxied from the @RTPTransport@ and as such has the same data as the @RTPTransportICENegotiationDidSucceed@.
994
995
*AudioStreamICENegotiationDidFail*
996
>This notification is proxied from the @RTPTransport@ and as such has the same data as the @RTPTransportICENegotiationDidFail@.
997
998
*AudioStreamDidTimeout*
999
>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@).
1000
1001
1002
h3. MSRPStreamBase
1003
1004
1005 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/msrp.py]
1006
1007 147 Adrian Georgescu
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.
1008 1 Adrian Georgescu
1009 147 Adrian Georgescu
1010
h4. methods
1011
1012 1 Adrian Georgescu
 
1013 147 Adrian Georgescu
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.
1014 1 Adrian Georgescu
1015
1016 147 Adrian Georgescu
h4. attributes
1017 1 Adrian Georgescu
1018
1019 147 Adrian Georgescu
The attributes defined in the @IMediaStream@ interface which are not provided by this class are:
1020
* type
1021
* priority
1022 1 Adrian Georgescu
1023 147 Adrian Georgescu
In addition, the following attributes need to be defined in the subclass in order for the @MSRPStreamBase@ class to take the correct decisions
1024 1 Adrian Georgescu
1025 147 Adrian Georgescu
*media_type*
1026
>The media type as included in the SDP (eg. @"message"@, @"application"@).
1027 1 Adrian Georgescu
1028 147 Adrian Georgescu
*accept_types*
1029
>A list of the MIME types which should be accepted by the stream (this is also sent within the SDP).
1030 1 Adrian Georgescu
1031 147 Adrian Georgescu
*accept_wrapped_types*
1032
>A list of the MIME types which should be accepted by the stream while wrapped in a @message/cpim@ envelope.
1033 1 Adrian Georgescu
1034 147 Adrian Georgescu
*use_msrp_session*
1035
>A boolean indicating whether or not an @MSRPSession@ should be used.
1036 1 Adrian Georgescu
1037
1038 147 Adrian Georgescu
h4. notifications
1039 1 Adrian Georgescu
1040
1041 147 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.
1042 1 Adrian Georgescu
1043 147 Adrian Georgescu
1044
*MSRPTransportTrace*
1045
>This notification is sent when an MSRP message is received for logging purposes.
1046
  
1047
timestamp:
1048
1049
>A @datetime.datetime@ object indicating when the notification was sent.
1050
  
1051
direction:
1052
1053
>The direction of the message, @"incoming"@ or @"outgoing"@.
1054
  
1055
data:
1056
1057
>The MSRP message as a string.
1058
1059
*MSRPLibraryLog*
1060
>This notification is sent anonymously whenever the MSRP library needs to log any information.
1061
  
1062
timestamp:
1063
1064
>A @datetime.datetime@ object indicating when the notification was sent.
1065
  
1066
message:
1067
1068
>The log message as a string.
1069
  
1070
level:
1071
1072
>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.
1073
1074
1075
h3. ChatStream
1076
1077
1078 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/msrp.py]
1079
1080 147 Adrian Georgescu
@sipsimple.streams.msrp.ChatStream@ implements session-based Instant Messaging (IM) over MSRP. This class performs the following functions:
1081 1 Adrian Georgescu
1082 147 Adrian Georgescu
* automatically wraps outgoing messages with Message/CPIM if that's necessary according to accept-types
1083
* unwraps incoming Message/CPIM messages; for each incoming message, the @ChatStreamGotMessage@ notification is posted
1084
* composes iscomposing payloads and reacts to those received by sending the @ChatStreamGotComposingIndication@ notification
1085 1 Adrian Georgescu
1086
An example of an SDP created using this class follows:
1087
1088 147 Adrian Georgescu
<pre>
1089 1 Adrian Georgescu
Content-Type: application/sdp
1090
Content-Length:   283
1091
1092
v=0
1093
o=- 3467525214 3467525214 IN IP4 192.168.1.6
1094
s=blink-0.10.7-beta
1095
c=IN IP4 192.168.1.6
1096
t=0 0
1097
m=message 2855 TCP/TLS/MSRP *
1098
a=path:msrps://192.168.1.6:2855/ca7940f12ddef14c3c32;tcp
1099
a=accept-types:message/cpim text/* application/im-iscomposing+xml
1100
a=accept-wrapped-types:*
1101 147 Adrian Georgescu
</pre>
1102 1 Adrian Georgescu
1103
1104 147 Adrian Georgescu
h4. methods
1105 1 Adrian Georgescu
1106
1107
1108 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *account*, *direction*=@'sendrecv'@)
1109
>Initializes the ChatStream instance.
1110 1 Adrian Georgescu
1111 147 Adrian Georgescu
1112
*send_message*(_self_, *content*, *content_type*=@'text/plain'@, *recipients*=@None@, *courtesy_recipients*=@None@, *subject*=@None@, _timestamp_=@None@, *required*=@None@, *additional_headers*=@None@)
1113
>Sends an IM message. Prefer Message/CPIM wrapper if it is supported. If called before the connection was established, the messages will be
1114
>queued until the stream starts.
1115
>Returns the generated MSRP message ID.
1116
  
1117
content:
1118
1119
>The content of the message.
1120
  
1121
content_type:
1122
1123
>Content-Type of wrapped message if Message/CPIM is used (Content-Type of MSRP message is always Message/CPIM in that case);
1124
>otherwise, Content-Type of MSRP message.
1125
  
1126
recipients:
1127
1128
>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.
1129
>May only differ from the default one if the remote party supports private messages. If it does not, a @ChatStreamError@ will be raised.
1130
  
1131
courtesy_recipients:
1132
1133
>The list of @CPIMIdentity@ objects which will be used for the @cc@ header of the CPIM wrapper.
1134
>May only be specified if the remote party supports private messages and CPIM is supported. If it does not, a @ChatStreamError@ will be raised.
1135
  
1136
subject:
1137
1138
>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.
1139
  
1140
required:
1141
1142
>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.
1143
  
1144
additional_headers:
1145
1146
>A list of MSRP header objects which will be added to this CPIM message. If CPIM is not supported, a @ChatStreamError@ will be raised.
1147
  
1148
timestamp:
1149
1150
>A @datetime.datetime@ object representing the timestamp to put on the CPIM wrapper of the message.
1151
>When set to @None@, a default one representing the current moment will be added.
1152
1153 1 Adrian Georgescu
 These MSRP headers are used to enable end-to-end success reports and to disable hop-to-hop successful responses:
1154 147 Adrian Georgescu
<pre>
1155 1 Adrian Georgescu
Failure-Report: partial
1156
Success-Report: yes
1157 147 Adrian Georgescu
</pre>
1158 1 Adrian Georgescu
1159
1160 147 Adrian Georgescu
*send_composing_indication*(_self_, _state_, _refresh_, _last_active=None_, _recipients=None_)
1161
>Sends an is-composing message to the listed recipients.
1162
  
1163
state:
1164 1 Adrian Georgescu
1165 147 Adrian Georgescu
>The state of the endpoint, @"active"@ or @"idle"@.
1166
  
1167
refresh:
1168 1 Adrian Georgescu
1169 147 Adrian Georgescu
>How often the local endpoint will send is-composing indications to keep the state from being reverted to @"idle"@.
1170
  
1171
last_active:
1172 1 Adrian Georgescu
1173 147 Adrian Georgescu
>A @datatime.datetime@ object representing the moment when the local endpoint was last active.
1174
  
1175
recipients:
1176 1 Adrian Georgescu
1177 147 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.
1178
>May only differ from the default one if the remote party supports private messages. If it does not, a @ChatStreamError@ will be raised.
1179 1 Adrian Georgescu
1180
1181 147 Adrian Georgescu
h4. notifications
1182 1 Adrian Georgescu
1183
1184
1185 147 Adrian Georgescu
*ChatStreamGotMessage*
1186
>Sent whenever a new incoming message is received,
1187
  
1188
timestamp:
1189 1 Adrian Georgescu
1190 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
1191
  
1192
message:
1193 1 Adrian Georgescu
1194 147 Adrian Georgescu
>A @ChatMessage@ or @CPIMMessage@ instance, depending on whether a CPIM message was received or not.
1195 1 Adrian Georgescu
1196 147 Adrian Georgescu
*ChatStreamDidDeliverMessage*
1197
>Sent when a successful report is received.
1198
  
1199
timestamp:
1200 1 Adrian Georgescu
1201 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
1202
  
1203
message_id:
1204 1 Adrian Georgescu
1205 147 Adrian Georgescu
>Text identifier of the message.
1206
  
1207
code:
1208 1 Adrian Georgescu
1209 147 Adrian Georgescu
>The status code received. Will always be 200 for this notification.
1210
  
1211
reason:
1212 1 Adrian Georgescu
1213 147 Adrian Georgescu
>The status reason received.
1214
  
1215
chunk:
1216 1 Adrian Georgescu
1217 147 Adrian Georgescu
>A @msrplib.protocol.MSRPData@ instance providing all the MSRP information about the report.
1218 1 Adrian Georgescu
1219 147 Adrian Georgescu
*ChatStreamDidNotDeliverMessage*
1220
>Sent when a failure report is received.
1221
  
1222
timestamp:
1223 1 Adrian Georgescu
1224 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
1225
  
1226
message_id:
1227 1 Adrian Georgescu
1228 147 Adrian Georgescu
>Text identifier of the message.
1229
  
1230
code:
1231
1232
>The status code received.
1233
  
1234
reason:
1235
1236
>The status reason received.
1237
  
1238
chunk:
1239
1240
>A @msrplib.protocol.MSRPData@ instance providing all the MSRP information about the report.
1241
1242
*ChatStreamDidSendMessage*
1243
>Sent when an outgoing message has been sent.
1244
  
1245
timestamp:
1246
1247
>A @datetime.datetime@ object indicating when the notification was sent.
1248
  
1249
message:
1250
1251
>A @msrplib.protocol.MSRPData@ instance providing all the MSRP information about the sent message.
1252
1253
*ChatStreamGotComposingIndication*
1254
>Sent when a is-composing payload is received.
1255
  
1256
timestamp:
1257
1258
>A @datetime.datetime@ object indicating when the notification was sent.
1259
  
1260
state:
1261
1262
>The state of the endpoint, @"active"@ or @"idle"@.
1263
  
1264
refresh:
1265
1266
>How often the remote endpoint will send is-composing indications to keep the state from being reverted to @"idle"@. May be @None@.
1267
  
1268
last_active:
1269
1270
>A @datatime.datetime@ object representing the moment when the remote endpoint was last active. May be @None@.
1271
  
1272
content_type:
1273
1274
>The MIME type of message being composed. May be @None@.
1275
  
1276
sender:
1277
1278
>The @ChatIdentity@ or @CPIMIdentity@ instance which identifies the sender of the is-composing indication.
1279
  
1280
recipients:
1281
1282
>The @ChatIdentity@ or @CPIMIdentity@ instances list which identifies the recipients of the is-composing indication.
1283
1284
1285
h3. FileSelector
1286
1287
1288
The @FileSelector@ is used to contain information about a file tranfer using the @FileTransferStream@ documented below.
1289
1290
1291
h4. methods
1292
1293
1294
1295
*<notextile>__init__</notextile>*(_self_, *name*=@None@, *type*=@None@, *size*=@None@, *hash*=@None@, *fd*=@None@)
1296
>Instantiate a new @FileSelector@. All the arguments are also available as attributes.
1297
  
1298
name:
1299
1300
>The filename (should be just the base name).
1301
  
1302
type:
1303
1304
>The type of the file.
1305
  
1306
size:
1307
1308
>The size of the file in bytes.
1309
  
1310
hash:
1311
1312
>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.
1313
  
1314
fd:
1315
1316
>A file descriptor if the application has already opened the file.
1317
1318
*parse*(_cls_, *string*)
1319
>Parses a file selector from the SDP @file-selector@ a attribute and returns a @FileSelector@ instance.
1320
1321
*for_file*(_cls_, *path*, *content_type*, *compute_hash*=@True@)
1322
>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.
1323
  
1324
path:
1325
1326
>The full path to the file.
1327
  
1328
content_type:
1329
1330
>An optional MIME type which is to be included in the file-selector.
1331
  
1332
compute_hash:
1333
1334
>Whether or not this method should compute the hash of the file.
1335
1336
*compute_hash*(_self_)
1337
>Compute the hash for this file selector. This method will block while the hash is computed, a potentially long operation for large files. 
1338
1339
1340
h4. attributes
1341
1342
1343
1344
*sdp_repr*
1345
>The SDP representation of the file-selector according to the RFC. This should be the value of the @file-selector@ SDP attribute.
1346
1347
1348
h3. FileTransferStream
1349
1350
1351 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/msrp.py]
1352
1353 147 Adrian Georgescu
The @FileTransferStream@ supports file transfer over MSRP according to RFC5547. An example of SDP constructed using this stream follows:
1354 1 Adrian Georgescu
1355 147 Adrian Georgescu
<pre>
1356 1 Adrian Georgescu
Content-Type: application/sdp
1357
Content-Length:   383
1358
1359
v=0
1360
o=- 3467525166 3467525166 IN IP4 192.168.1.6
1361
s=blink-0.10.7-beta
1362
c=IN IP4 192.168.1.6
1363
t=0 0
1364
m=message 2855 TCP/TLS/MSRP *
1365
a=path:msrps://192.168.1.6:2855/e593357dc9abe90754bd;tcp
1366
a=sendonly
1367
a=accept-types:*
1368
a=accept-wrapped-types:*
1369
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
1370 147 Adrian Georgescu
</pre>
1371 1 Adrian Georgescu
1372
1373 147 Adrian Georgescu
h4. methods
1374 1 Adrian Georgescu
1375
1376
1377 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *account*, *file_selector*=@None@)
1378
>Instantiate a new @FileTransferStream@. If this is constructed by the application for an outgoing file transfer, the @file_selector@ argument must be present.
1379
  
1380
account:
1381 1 Adrian Georgescu
1382 147 Adrian Georgescu
>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ instance which will be associated with the stream.
1383
  
1384
file_selector:
1385 1 Adrian Georgescu
1386 147 Adrian Georgescu
>The @FileSelector@ instance which represents the file which is to be transferred.
1387 1 Adrian Georgescu
1388
1389 147 Adrian Georgescu
h4. notifications
1390 1 Adrian Georgescu
1391
1392
1393 147 Adrian Georgescu
*FileTransferStreamDidDeliverChunk*
1394
>This notification is sent for an outgoing file transfer when a success report is received about part of the file being transferred.
1395
  
1396
timestamp:
1397 1 Adrian Georgescu
1398 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
1399
  
1400
message_id:
1401
1402
>The MSRP message ID of the file transfer session.
1403
  
1404
chunk:
1405
1406
>An @msrplib.protocol.MSRPData@ instance represented the received REPORT.
1407
  
1408
code:
1409
1410
>The status code received. Will always be 200 for this notification.
1411
  
1412
reason:
1413
1414
>The status reason received.
1415
  
1416
transferred_bytes:
1417
1418
>The number of bytes which have currently been successfully transferred.
1419
  
1420
file_size:
1421
1422
>The size of the file being transferred.
1423
1424
*FileTransferStreamDidNotDeliverChunk*
1425
  
1426
timestamp:
1427
1428
>A @datetime.datetime@ object indicating when the notification was sent.
1429
>This notification is sent for an outgoing file transfer when a failure report is received about part of the file being transferred.
1430
  
1431
message_id:
1432
1433
>The MSRP message ID of the file transfer session.
1434
  
1435
chunk:
1436
1437
>An @msrplib.protocol.MSRPData@ instance represented the received REPORT.
1438
  
1439
code:
1440
1441
>The status code received.
1442
  
1443
reason:
1444
1445
>The status reason received.
1446
1447
*FileTransferStreamDidFinish*
1448
>This notification is sent when the incoming or outgoing file transfer is finished.
1449
  
1450
timestamp:
1451
1452
>A @datetime.datetime@ object indicating when the notification was sent.
1453
1454
*FileTransferStreamGotChunk*
1455
>This notificaiton is sent for an incoming file transfer when a chunk of file data is received.
1456
  
1457
timestamp:
1458
1459
>A @datetime.datetime@ object indicating when the notification was sent.
1460
  
1461
content:
1462
1463
>The file part which was received, as a @str@.
1464
  
1465
content_type:
1466
1467
>The MIME type of the file which is being transferred.
1468
  
1469
transferred_bytes:
1470
1471
>The number of bytes which have currently been successfully transferred.
1472
  
1473
file_size:
1474
1475
>The size of the file being transferred.
1476
1477
1478
1479
h3. IDesktopSharingHandler
1480
1481
1482
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:
1483
* InternalVNCViewerHandler
1484
* InternalVNCServerHandler
1485
* ExternalVNCViewerHandler
1486
* ExternalVNCServerHandler
1487
1488
1489
h4. methods
1490
1491 1 Adrian Georgescu
 
1492 72 Luci Stanescu
1493 147 Adrian Georgescu
*initialize*(_self_, *stream*)
1494
>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.
1495 72 Luci Stanescu
1496 1 Adrian Georgescu
1497 147 Adrian Georgescu
h4. attributes
1498 1 Adrian Georgescu
1499
1500
1501 147 Adrian Georgescu
*type*
1502
  @"active"@ or @"passive"@ depending on whether the handler represents a VNC viewer or server respectively.
1503 1 Adrian Georgescu
1504 94 Adrian Georgescu
1505 147 Adrian Georgescu
h4. notifications
1506 1 Adrian Georgescu
1507
1508
1509 147 Adrian Georgescu
*DesktopSharingHandlerDidFail*
1510
>This notification must be sent by the handler when an error occurs to notify the stream that it should fail.
1511
  
1512
context:
1513 72 Luci Stanescu
1514 147 Adrian Georgescu
>A string describing when the handler failed, such as @"reading"@, @"sending"@ or @"connecting"@.
1515
  
1516
failure:
1517 72 Luci Stanescu
1518 147 Adrian Georgescu
>A @twisted.python.failure.Failure@ instance describing the exception which led to the failure.
1519
  
1520
reason:
1521 1 Adrian Georgescu
1522 147 Adrian Georgescu
>A string describing the failure reason.
1523 1 Adrian Georgescu
1524
1525 147 Adrian Georgescu
h3. InternalVNCViewerHandler
1526 1 Adrian Georgescu
1527
1528 147 Adrian Georgescu
This is a concrete implementation of the @IDesktopSharingHandler@ interface which can be used for a VNC viewer implemented within the application.
1529 1 Adrian Georgescu
1530
1531 147 Adrian Georgescu
h4. methods
1532 1 Adrian Georgescu
1533
1534
1535 147 Adrian Georgescu
*send*(_self_, *data*)
1536
>Sends the specified data to the stream in order for it to be transported over MSRP to the remote endpoint.
1537
  
1538
data:
1539 1 Adrian Georgescu
1540 147 Adrian Georgescu
>The RFB data to be transported over MSRP, in the form of a @str@.
1541 1 Adrian Georgescu
1542
1543 147 Adrian Georgescu
h4. notifications
1544 1 Adrian Georgescu
1545
1546
1547 147 Adrian Georgescu
*DesktopSharingStreamGotData*
1548
>This notification is sent when data is received over MSRP.
1549
  
1550
data:
1551 1 Adrian Georgescu
1552 147 Adrian Georgescu
>The RFB data from the remote endpoint, in the form of a @str@.
1553 1 Adrian Georgescu
1554
1555 147 Adrian Georgescu
h3. InternalVNCServerHandler
1556 1 Adrian Georgescu
1557
1558 147 Adrian Georgescu
This is a concrete implementation of the @IDesktopSharingHandler@ interface which can be used for a VNC server implemented within the application.
1559 1 Adrian Georgescu
1560
1561 147 Adrian Georgescu
h4. methods
1562 1 Adrian Georgescu
1563
1564
1565 147 Adrian Georgescu
*send*(_self_, *data*)
1566
>Sends the specified data to the stream in order for it to be transported over MSRP to the remote endpoint.
1567
  
1568
data:
1569
1570
>The RFB data to be transported over MSRP, in the form of a @str@.
1571
1572
1573
h4. notifications
1574
1575
1576
1577
*DesktopSharingStreamGotData*
1578
>This notification is sent when data is received over MSRP.
1579
  
1580
data:
1581
1582
>The RFB data from the remote endpoint, in the form of a @str@.
1583
1584
1585
h3. ExternalVNCViewerHandler
1586
1587
1588
This implementation of @IDesktopSharingHandler@ can be used for an external VNC viewer which connects to a VNC server using TCP.
1589
1590
1591
h4. methods
1592
1593
1594
1595
*<notextile>__init__</notextile>*(_self_, *address*=@("localhost", 0)@, *connect_timeout*=@3@)
1596
>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.
1597
  
1598
address:
1599
1600
>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.
1601
1602
1603
h4. attributes
1604
1605
1606
1607
*address*
1608
>A tuple containing an IP address and a port on which the handler is listening.
1609
1610
1611
h3. ExternalVNCServerHandler
1612
1613
1614
This implementation of @IDesktopSharingHandler@ can be used for an external VNC server to which handler will connect using TCP.
1615
1616
1617
h4. methods
1618
1619
1620
1621
*<notextile>__init__</notextile>*(_self_, *address*, *connect_timeout*=@3@)
1622
>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.
1623
  
1624
address:
1625
1626
>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.
1627
  
1628
connect_timeout:
1629
1630
>How long to wait to connect to the VNC server before giving up.
1631
1632
1633
1634
h3. DesktopSharingStream
1635
1636
1637 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/msrp.py]
1638
1639
This stream implements desktop sharing using MSRP as a transport protocol for RFB data.
1640
1641 147 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 "MSRP relay":http://msrprelay.org configured for the called party domain is needed. Below is an example of the Session Description Protocol used for establishing a Desktop sharing session:
1642 1 Adrian Georgescu
1643 147 Adrian Georgescu
<pre>
1644 1 Adrian Georgescu
m=application 2855 TCP/TLS/MSRP *
1645
a=path:msrps://10.0.1.19:2855/b599b22d1b1d6a3324c8;tcp
1646
a=accept-types:application/x-rfb
1647
a=rfbsetup:active
1648 147 Adrian Georgescu
</pre>
1649 1 Adrian Georgescu
1650
1651
1652 147 Adrian Georgescu
h4. methods
1653 1 Adrian Georgescu
1654
1655
1656 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *acount*, *handler*)
1657
>Instantiate a new @DesktopSharingStream@.
1658
  
1659
account:
1660 1 Adrian Georgescu
1661 147 Adrian Georgescu
>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ instance this stream is associated with.
1662
  
1663
handler:
1664 1 Adrian Georgescu
1665 147 Adrian Georgescu
>An object implementing the @IDesktopSharingHandler@ interface which will act as the handler for RFB data.
1666 1 Adrian Georgescu
1667
1668 147 Adrian Georgescu
h4. attributes
1669 1 Adrian Georgescu
1670
1671
1672 147 Adrian Georgescu
*handler*
1673
>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.
1674 1 Adrian Georgescu
1675 147 Adrian Georgescu
*incoming_queue*
1676
>A @eventlet.coros.queue@ instance on which incoming RFB data is written. The handler should wait for data on this queue.
1677 1 Adrian Georgescu
1678 147 Adrian Georgescu
*outgoing_queue*
1679
>A @eventlet.coros.queue@ instance on which outgoing RFB data is written. The handler should write data on this queue.
1680 1 Adrian Georgescu
1681
1682 147 Adrian Georgescu
h3. ConferenceHandler
1683 1 Adrian Georgescu
1684
1685 147 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.
1686 1 Adrian Georgescu
1687 147 Adrian Georgescu
Adding and removing participants is performed using a @REFER@ request as explained in RFC 4579, section 5.5.
1688 1 Adrian Georgescu
1689 147 Adrian Georgescu
In addition, the @ConferenceHandler@ will subscribe to the @conference@ event in order to get information about participants in the conference.
1690 1 Adrian Georgescu
1691
1692 147 Adrian Georgescu
h4. methods
1693 1 Adrian Georgescu
1694
1695 147 Adrian Georgescu
*add_participant*(_self_, *participant_uri*)
1696
>Send a @REFER@ request telling the server to invite the participant specified in @participant_uri@ to join the ongoing conference.
1697 1 Adrian Georgescu
1698 147 Adrian Georgescu
*remove_participant*(_self_, *participant_uri*)
1699
>Send a @REFER@ request telling the server to remove the participant specified in @participant_uri@ from the ongoing conference.
1700 1 Adrian Georgescu
1701
1702 147 Adrian Georgescu
h4. notifications
1703
1704
1705
 All notifications are sent with the @Session@ object as the sender.
1706
1707
*SIPSessionGotConferenceInfo*
1708
>This notification is sent when a @NOTIFY@ is received with a valid conferene payload.
1709
  
1710
timestamp:
1711
1712
>A @datetime.datetime@ object indicating when the notification was sent.
1713
  
1714
conference_info:
1715
1716
>The @Conference@ payload object.
1717
1718
*SIPConferenceDidAddParticipant*
1719
>This notification is sent when a participant was successfully added to the conference.
1720
  
1721
timestamp:
1722
1723
>A @datetime.datetime@ object indicating when the notification was sent.
1724
  
1725
participant:
1726
1727
>URI of the participant added to the conference.
1728
1729
*SIPConferenceDidNotAddParticipant*
1730
>This notification is sent when a participant could not be added to the conference.
1731
  
1732
timestamp:
1733
1734
>A @datetime.datetime@ object indicating when the notification was sent.
1735
  
1736
participant:
1737
1738
>URI of the participant added to the conference.
1739
  
1740
code:
1741
1742
>SIP response code for the failure.
1743
  
1744
reason:
1745
1746
>Reason for the failure.
1747
1748
*SIPConferenceDidRemoveParticipant*
1749
>This notification is sent when a participant was successfully removed from the conference.
1750
  
1751
timestamp:
1752
1753
>A @datetime.datetime@ object indicating when the notification was sent.
1754
  
1755
participant:
1756
1757
>URI of the participant removed from the conference.
1758
1759
*SIPConferenceDidNotRemoveParticipant*
1760
>This notification is sent when a participant could not be removed from the conference.
1761
  
1762
timestamp:
1763
1764
>A @datetime.datetime@ object indicating when the notification was sent.
1765
  
1766
participant:
1767
1768
>URI of the participant removed from the conference.
1769
  
1770
code:
1771
1772
>SIP response code for the failure.
1773
  
1774
reason:
1775
1776
>Reason for the failure.
1777
1778
*SIPConferenceGotAddParticipantProgress*
1779
>This notification is sent when a @NOTIFY@ is received indicating the status of the add participant operation.
1780
  
1781
timestamp:
1782
1783
>A @datetime.datetime@ object indicating when the notification was sent.
1784
  
1785
participant:
1786
1787
>URI of the participant whose operation is in progress.
1788
  
1789
code:
1790
1791
>SIP response code for progress.
1792
  
1793
reason:
1794
1795
>Reason associated with the response code.
1796
1797
*SIPConferenceGotRemoveParticipantProgress*
1798
>This notification is sent when a @NOTIFY@ is received indicating the status of the remove participant operation.
1799
  
1800
timestamp:
1801
1802
>A @datetime.datetime@ object indicating when the notification was sent.
1803
  
1804
participant:
1805
1806
>URI of the participant whose operation is in progress.
1807
  
1808
code:
1809
1810
>SIP response code for progress.
1811
  
1812
reason:
1813
1814
>Reason associated with the response code.
1815
1816
1817
h2. Address Resolution
1818
1819
1820
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.
1821
1822 1 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. 
1823
1824
1825 147 Adrian Georgescu
h3. DNS Manager
1826 1 Adrian Georgescu
1827
1828 147 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.
1829 1 Adrian Georgescu
1830 122 Adrian Georgescu
1831 147 Adrian Georgescu
h4. methods
1832 122 Adrian Georgescu
1833 121 Adrian Georgescu
1834 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
1835
>Instantiate the DNSManager object (it's a Singleton).
1836 121 Adrian Georgescu
1837 147 Adrian Georgescu
*start*(_self_)
1838
>Start the DNSManager. It will start the probing process to determine the suitable nameservers to use.
1839 1 Adrian Georgescu
1840 147 Adrian Georgescu
*stop*(_self_)
1841
>Stop the DNS resolution probing.
1842 1 Adrian Georgescu
1843 112 Luci Stanescu
1844 1 Adrian Georgescu
1845 147 Adrian Georgescu
h4. notifications
1846
1847
1848
*DNSResolverDidInitialize*
1849
>This notification is sent when the nameservers to use for probing (and further DNS lookups) have been set for the first time.
1850
  
1851
timestamp:
1852
1853
>A @datetime.datetime@ object indicating when the notification was sent.
1854
  
1855
nameservers:
1856
1857
>The list of nameservers that was set on the DNS Manager.
1858
1859
*DNSNameserversDidChange*
1860
>This notification is sent when the nameservers to use for probing (and further DNS lookups) have changed as a result of the probing process.
1861
  
1862
timestamp:
1863
1864
>A @datetime.datetime@ object indicating when the notification was sent.
1865
  
1866
nameservers:
1867
1868
>The list of nameservers that was set on the DNS Manager.
1869
1870
1871
1872
h3. DNS Lookup
1873
1874
1875 1 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.
1876
1877
1878 147 Adrian Georgescu
h4. methods
1879 1 Adrian Georgescu
1880
1881 127 Adrian Georgescu
1882 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
1883
>Instantiate a new DNSLookup object.
1884 129 Adrian Georgescu
1885 147 Adrian Georgescu
*lookup_service*(_self_, *uri*, *service*, *timeout*=@3.0@, *lifetime*=@15.0@)
1886
>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.
1887
  
1888
uri:
1889 127 Adrian Georgescu
1890 147 Adrian Georgescu
>A @(Frozen)SIPURI@ from which the @host@ attribute is used for the query domain.
1891
  
1892
service:
1893 1 Adrian Georgescu
1894 147 Adrian Georgescu
>The service to lookup servers for, @"msrprelay"@ or @"stun"@.
1895
  
1896
timeout:
1897 129 Adrian Georgescu
1898 147 Adrian Georgescu
>How many seconds to wait for a response from a nameserver.
1899
  
1900
lifetime:
1901 129 Adrian Georgescu
1902 147 Adrian Georgescu
>How many seconds to wait for a response from all nameservers in total.
1903 1 Adrian Georgescu
1904 147 Adrian Georgescu
*lookup_sip_proxy*(_self_, *uri*, *supported_transports*, *timeout*=@3.0@, *lifetime*=@15.0@)
1905
>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.
1906
  
1907
uri:
1908 129 Adrian Georgescu
1909 147 Adrian Georgescu
>A @(Frozen)SIPURI@ from which the @host@, @port@, @parameters@ and @secure@ attributes are used.
1910
  
1911
supported_transports:
1912 1 Adrian Georgescu
1913 147 Adrian Georgescu
>A sublist of @['udp', 'tcp', 'tls']@ in the application's order of preference.
1914
  
1915
timeout:
1916 129 Adrian Georgescu
1917 147 Adrian Georgescu
>How many seconds to wait for a response from a nameserver.
1918
  
1919
lifetime:
1920 1 Adrian Georgescu
1921 147 Adrian Georgescu
>How many seconds to wait for a response from all nameservers in total.
1922 129 Adrian Georgescu
1923 147 Adrian Georgescu
*lookup_xcap_server*(_self_, *uri*, *timeout*=@3.0@, *lifetime*=@15.0@)
1924
>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.
1925
  
1926
uri:
1927 1 Adrian Georgescu
1928 147 Adrian Georgescu
>A @(Frozen)SIPURI@ from which the @host@ attribute is used for the query domain.
1929
  
1930
timeout:
1931 129 Adrian Georgescu
1932 147 Adrian Georgescu
>How many seconds to wait for a response from a nameserver.
1933
  
1934
lifetime:
1935 1 Adrian Georgescu
1936 147 Adrian Georgescu
>How many seconds to wait for a response from all nameservers in total.
1937
1938
1939
1940
h4. notifications
1941
1942
1943
1944
*DNSLookupDidSucceed*
1945
>This notification is sent when one of the lookup methods succeeds in finding a result.
1946
  
1947
timestamp:
1948
1949
>A @datetime.datetime@ object indicating when the notification was sent.
1950
  
1951
result:
1952
1953
>The result of the DNS lookup in the format described in each method.
1954
1955
*DNSLookupDidFail*
1956
>This notification is sent when one of the lookup methods fails in finding a result.
1957
  
1958
timestamp:
1959
1960
>A @datetime.datetime@ object indicating when the notification was sent.
1961
  
1962
error:
1963
1964
>A @str@ object describing the error which resulted in the DNS lookup failure.
1965
1966
*DNSLookupTrace*
1967
>This notification is sent several times during a lookup process for each individual DNS query.
1968
  
1969
timestamp:
1970
1971
>A @datetime.datetime@ object indicating when the notification was sent.
1972
  
1973
query_type:
1974
1975
>The type of the query, @"NAPTR"@, @"SRV"@, @"A"@, @"NS"@ etc.
1976
  
1977
query_name:
1978
1979
>The name which was queried.
1980
  
1981
answer:
1982
1983
>The answer returned by dnspython, or @None@ if an error occurred.
1984
  
1985
error:
1986
1987
>The exception which caused the query to fail, or @None@ if no error occurred.
1988
  
1989
context:
1990
1991
>The name of the method which was called on the @DNSLookup@ object.
1992
  
1993
service:
1994
1995
>The service which was queried for, only available when context is @"lookup_service"@.
1996
  
1997
uri:
1998
1999
>The uri which was queried for.
2000
  
2001
nameservers:
2002
2003
>The list of nameservers that was used to perform the lookup.
2004
2005
2006
2007
h3. Route
2008
2009
2010
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.
2011
2012
2013
h4. methods
2014
2015
2016
2017
*<notextile>__init__</notextile>*(_self_, *address*, *port*=None, *transport*=@'udp'@)
2018
>Creates the Route object with the specified parameters as attributes.
2019
>Each of these attributes can be accessed on the object once instanced.
2020
  
2021
>+_address_+:
2022
2023
>The IPv4 address that the request in question should be sent to as a string.
2024
  
2025
>+_port_+:
2026
2027
>The port to send the requests to, represented as an int, or None if the default port is to be used.
2028
  
2029
>+_transport_+:
2030
2031
>The transport to use, this can be a string of either "udp", "tcp" or "tls" (case insensitive).
2032
2033
*get_uri*(_self_)
2034
>Returns a @SIPURI@ object which contains the adress, port and transport as parameter. This can be used to easily construct a @RouteHeader@:
2035
  <pre>
2036 87 Adrian Georgescu
    route = Route("1.2.3.4", port=1234, transport="tls")
2037
    route_header = RouteHeader(route.get_uri())
2038 147 Adrian Georgescu
</pre>
2039 87 Adrian Georgescu
2040
2041
2042 147 Adrian Georgescu
h2. SIP Accounts
2043 87 Adrian Georgescu
2044
2045 147 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.
2046 87 Adrian Georgescu
2047
2048 147 Adrian Georgescu
h3. AccountManager
2049 87 Adrian Georgescu
2050 94 Adrian Georgescu
2051 147 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.
2052 87 Adrian Georgescu
2053
2054 147 Adrian Georgescu
h4. methods
2055 87 Adrian Georgescu
2056
2057
2058 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
2059
>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.
2060 87 Adrian Georgescu
2061 147 Adrian Georgescu
*start*(_self_)
2062
>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 [[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.
2063 87 Adrian Georgescu
2064 147 Adrian Georgescu
*stop*(_self_)
2065
>Calling this method will deactivate all accounts managed by the @AccountManager@. This method is called automatically by the SIPApplication when it stops.
2066 87 Adrian Georgescu
2067 147 Adrian Georgescu
*has_account*(_self_, *id*)
2068
>This method returns @True@ if an account which has the specifed SIP ID (must be a string) exists and @False@ otherwise.
2069 87 Adrian Georgescu
2070 147 Adrian Georgescu
*get_account*(_self_, *id*)
2071
>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.
2072 87 Adrian Georgescu
2073 147 Adrian Georgescu
*get_accounts*(_self_)
2074
>Returns a list containing all the managed accounts.
2075 87 Adrian Georgescu
2076 147 Adrian Georgescu
*iter_accounts*(_self_)
2077
>Returns an iterator through all the managed accounts.
2078
2079
*find_account*(_self_, *contact_uri*)
2080
>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.
2081
2082
2083
h4. notifications
2084
2085
2086
2087
*SIPAccountManagerDidAddAccount*
2088
>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.
2089
  
2090
>+_timestamp_+:
2091
2092
>A @datetime.datetime@ object indicating when the notification was sent.
2093
  
2094
>+_account_+:
2095
2096
>The account object which was added.
2097
2098
*SIPAccountManagerDidRemoveAccount*
2099
>This notification is sent when an account is deleted using the @delete@ method.
2100
  
2101
>+_timestamp_+:
2102
2103
>A @datetime.datetime@ object indicating when the notification was sent.
2104
  
2105
>+_account_+:
2106
2107
>The account object which was deleted.
2108
2109
*SIPAccountManagerDidChangeDefaultAccount*
2110
>This notification is sent when the default account changes.
2111
  
2112
>+_timestamp_+:
2113
2114
>A @datetime.datetime@ object indicating when the notification was sent.
2115
  
2116
>+_old_account_+:
2117
2118 133 Adrian Georgescu
   This is the account object which used to be the default account.
2119 147 Adrian Georgescu
  
2120
>+_account_+:
2121
2122 87 Adrian Georgescu
   This is the account object which is the new default account.
2123
2124
2125 147 Adrian Georgescu
h3. Account
2126 87 Adrian Georgescu
2127
2128 147 Adrian Georgescu
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 [[SipConfigurationAPI#Account|Configuration API]].
2129 87 Adrian Georgescu
2130 147 Adrian Georgescu
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 [[SipMiddlewareApi#AccountManager|AccountManager]]. The next sections will use a lowercase, monospaced @account@ to represent an instance of @Account@.
2131
2132
2133
h4. states
2134
2135
2136
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:
2137
<pre>
2138 87 Adrian Georgescu
account.enabled = True
2139
account.save()
2140 147 Adrian Georgescu
</pre>
2141 87 Adrian Georgescu
2142 147 Adrian Georgescu
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.
2143 87 Adrian Georgescu
2144 147 Adrian Georgescu
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.
2145 87 Adrian Georgescu
2146 147 Adrian Georgescu
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:
2147 87 Adrian Georgescu
2148
2149 147 Adrian Georgescu
*Account.registration.enabled*
2150
>This flag controls the automatic registration of the account. The notifications *SIPAccountRegistrationDidSucceed*, *SIPAccountRegistrationDidFail* and *SIPAccountRegistrationDidEnd* are used to inform the status of this registration.
2151 87 Adrian Georgescu
2152 147 Adrian Georgescu
*Account.presence.enabled*
2153
>This flag controls the automatic subscription to buddies for the _presence_ event and the publication of data in this event. (Not implemented yet)
2154 87 Adrian Georgescu
2155 147 Adrian Georgescu
*Account.dialog_event.enabled*
2156
>This flag controls the automatic subscription to buddies for the _dialog-info_ event and the publication of data in this event. (Not implemented yet)
2157 87 Adrian Georgescu
2158 147 Adrian Georgescu
*Account.message_summary.enabled*
2159
>This flag controls the automatic subscription to the _message-summary_ event in order to find out about voicemail messages. (Not implemented yet)
2160 87 Adrian Georgescu
2161 147 Adrian Georgescu
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 [[SipConfigurationAPI#SettingsObject|SettingsObject]].
2162 87 Adrian Georgescu
2163
2164 147 Adrian Georgescu
h4. attributes
2165
2166
2167 87 Adrian Georgescu
The following attributes can be used on an Account object and need to be considered read-only.
2168
2169 73 Luci Stanescu
2170 147 Adrian Georgescu
*id*
2171
>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@.
2172
  <pre>
2173 73 Luci Stanescu
  account.id # 'alice@example.com'
2174
  account.id.username # 'alice'
2175
  account.id.domain # 'example.com'
2176 147 Adrian Georgescu
</pre>
2177 73 Luci Stanescu
2178 147 Adrian Georgescu
*contact*
2179
>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.
2180
  <pre>
2181 73 Luci Stanescu
  account.contact # 'ContactURIFactory(username=hnfkybrt)'
2182
  account.contact.username # 'hnfkybrt'
2183 94 Adrian Georgescu
  account.contact['udp'] # <SIPURI "sip:hnfkybrt@10.0.0.1:53024">
2184 73 Luci Stanescu
  account.contact['tls'] # <SIPURI "sip:hnfkybrt@10.0.0.1:54478;transport=tls">
2185 147 Adrian Georgescu
</pre>
2186 94 Adrian Georgescu
2187 147 Adrian Georgescu
*credentials*
2188
>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.
2189
  <pre>
2190 73 Luci Stanescu
  account.credentials # <Credentials for 'alice'>
2191 147 Adrian Georgescu
</pre>
2192 94 Adrian Georgescu
2193 147 Adrian Georgescu
*uri*
2194
>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.
2195
  <pre>
2196 73 Luci Stanescu
  account.uri # <SIPURI "sip:alice@example.com">
2197 147 Adrian Georgescu
</pre>
2198 94 Adrian Georgescu
2199 73 Luci Stanescu
2200 147 Adrian Georgescu
h4. notifications
2201 94 Adrian Georgescu
2202 73 Luci Stanescu
2203
2204 147 Adrian Georgescu
*CFGSettingsObjectDidChange*
2205
>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 [[SipConfigurationAPI#SettingsObjectNotifications|SettingsObject Notifications]].
2206 1 Adrian Georgescu
2207 147 Adrian Georgescu
*SIPAccountWillActivate*
2208
>This notification is sent when the @Account@ is about to be activated, but before actually performing any activation task. See @SIPAccountDidActivate@ for more detail.
2209
  
2210
>+_timestamp_+:
2211 119 Luci Stanescu
2212 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2213 119 Luci Stanescu
2214 147 Adrian Georgescu
*SIPAccountDidActivate*
2215
>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.
2216
  
2217
>+_timestamp_+:
2218 119 Luci Stanescu
2219 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2220 119 Luci Stanescu
2221 147 Adrian Georgescu
*SIPAccountWillDeactivate*
2222
>This notification is sent when the @Account@ is about to be deactivated, but before performing any deactivation task. See @SIPAccountDidDeactivate@ for more detail.
2223
  
2224
>+_timestamp_+:
2225
2226
>A @datetime.datetime@ object indicating when the notification was sent.
2227
2228
*SIPAccountDidDeactivate*
2229
>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@.
2230
  
2231
>+_timestamp_+:
2232
2233
>A @datetime.datetime@ object indicating when the notification was sent.
2234
2235
*SIPAccountWillRegister*
2236
>This notification is sent when the account is about to register for the first time.
2237
  
2238
>+_timestamp_+:
2239
2240
>A @datetime.datetime@ object indicating when the notification was sent.
2241
2242
*SIPAccountRegistrationWillRefresh*
2243
>This notification is sent when a registration is about to be refreshed.
2244
  
2245
>+_timestamp_+:
2246
2247
>A @datetime.datetime@ object indicating when the notification was sent.
2248
2249
*SIPAccountRegistrationDidSucceed*
2250
>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:
2251
  
2252
>+_timestamp_+:
2253
2254
>A @datetime.datetime@ object indicating when the notification was sent.
2255
  
2256
>+_contact_header_+:
2257
2258 119 Luci Stanescu
   The Contact header which was registered.
2259 147 Adrian Georgescu
  
2260
>+_contact_header_list_+:
2261
2262 119 Luci Stanescu
   A list containing all the contacts registered for this SIP account.
2263 147 Adrian Georgescu
  
2264
>+_expires_+:
2265
2266 119 Luci Stanescu
   The amount in seconds in which this registration will expire.
2267 147 Adrian Georgescu
  
2268
>+_registrar_+:
2269 119 Luci Stanescu
2270 147 Adrian Georgescu
>The @sipsimple.util.Route@ object which was used.
2271
2272
*SIPAccountRegistrationDidFail*
2273
>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:
2274
  
2275
>+_timestamp_+:
2276
2277
>A @datetime.datetime@ object indicating when the notification was sent.
2278
  
2279
>+_error_+:
2280
2281 119 Luci Stanescu
   The reason for the failure of the REGISTER request.
2282 147 Adrian Georgescu
  
2283
>+_timeout_+:
2284 119 Luci Stanescu
2285 147 Adrian Georgescu
   The amount in seconds as a @float@ after which the registration will be tried again.
2286 119 Luci Stanescu
2287 147 Adrian Georgescu
*SIPAccountRegistrationDidEnd*
2288
>This notification is sent when a registration is ended (the account is unregistered). The data contained in this notification is:
2289
  
2290
>+_timestamp_+:
2291 119 Luci Stanescu
2292 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2293
  
2294
>+_registration_+:
2295 119 Luci Stanescu
2296 147 Adrian Georgescu
   The @sipsimple.core.Registration@ object which ended.
2297 119 Luci Stanescu
2298 147 Adrian Georgescu
*SIPAccountRegistrationDidNotEnd*
2299
>This notification is sent when a registration fails to end (the account is not unregistered). The data contained in this notification is:
2300
  
2301
>+_timestamp_+:
2302 119 Luci Stanescu
2303 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2304
  
2305
>+_code_+:
2306 119 Luci Stanescu
2307 147 Adrian Georgescu
>The SIP status code received.
2308
  
2309
>+_reason_+:
2310 119 Luci Stanescu
2311 147 Adrian Georgescu
>The SIP status reason received.
2312
  
2313
>+_registration_+:
2314 119 Luci Stanescu
2315 147 Adrian Georgescu
>The @sipsimple.core.Registration@ object which ended.
2316 119 Luci Stanescu
2317 147 Adrian Georgescu
*SIPAccountRegistrationGotAnswer*
2318
>This notification is sent whenever a response is received to a sent REGISTER request for this account. The data contained in this notification is:
2319
  
2320
>+_timestamp_+:
2321
2322
>A @datetime.datetime@ object indicating when the notification was sent.
2323
  
2324
>+_code_+:
2325
2326
>The SIP status code received.
2327
  
2328
>+_reason_+:
2329
2330
>The SIP status reason received.
2331
  
2332
>+_registration_+:
2333
2334
>The @sipsimple.core.Registration@ object which was used.
2335
  
2336
>+_registrar_+:
2337
2338
>The @sipsimple.util.Route@ object which was used.
2339
2340
*SIPAccountMWIDidGetSummary*
2341
>This notification is sent when a NOTIFY is received with a message-summary payload. The data contained in this notification is:
2342
  
2343
>+_timestamp_+:
2344
2345
>A @datetime.datetime@ object indicating when the notification was sent.
2346
  
2347
>+_message_summary_+:
2348
2349
>A @sipsimple.payloads.messagesummary.MessageSummary@ object with the parsed payload from the NOTIFY request.
2350
2351
2352
h3. BonjourAccount
2353
2354
2355
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.
2356
2357
2358
h4. states
2359
2360
2361
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.
2362
2363
2364
h4. attributes
2365
2366
2367 119 Luci Stanescu
The following attributes can be used on a BonjourAccount object and need to be considered read-only.
2368
2369
2370 147 Adrian Georgescu
*id*
2371
>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@.
2372
  <pre>
2373 119 Luci Stanescu
  bonjour_account.id # 'bonjour@local'
2374
  bonjour_account.id.username # 'bonjour'
2375
  bonjour_account.id.domain # 'local'
2376 147 Adrian Georgescu
</pre>
2377 119 Luci Stanescu
2378 147 Adrian Georgescu
*contact*
2379
>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.
2380
  <pre>
2381 119 Luci Stanescu
  bonjour_account.contact # 'ContactURIFactory(username=lxzvgack)'
2382
  bonjour_account.contact.username # 'lxzvgack'
2383
  bonjour_account.contact['udp'] # <SIPURI "sip:lxzvgack@10.0.0.1:53024">
2384
  bonjour_account.contact['tls'] # <SIPURI "sip:lxzvgack@10.0.0.1:54478;transport=tls">
2385 147 Adrian Georgescu
</pre>
2386 119 Luci Stanescu
2387 147 Adrian Georgescu
*credentials*
2388
>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.
2389
  <pre>
2390 119 Luci Stanescu
  bonjour_account.credentials # <Credentials for 'alice'>
2391 147 Adrian Georgescu
</pre>
2392 119 Luci Stanescu
2393 147 Adrian Georgescu
*uri*
2394
>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:
2395
  <pre>
2396 119 Luci Stanescu
  bonjour_account.uri # <SIPURI "sip:lxzvgack@10.0.0.1">
2397 147 Adrian Georgescu
</pre>
2398 119 Luci Stanescu
2399
2400 147 Adrian Georgescu
h4. notifications
2401 119 Luci Stanescu
2402
2403 147 Adrian Georgescu
*BonjourAccountDidAddNeighbour*
2404
>This notification is sent when a new Bonjour neighbour is discovered.
2405
  
2406
>+_service_description_+:
2407 119 Luci Stanescu
2408 147 Adrian Georgescu
>BonjourServiceDescription object uniquely identifying this neighbour in the mDNS library.
2409
  
2410
>+_display_name_+:
2411 119 Luci Stanescu
2412 147 Adrian Georgescu
>The name of the neighbour as it is published.
2413
  
2414
>+_host_+:
2415 119 Luci Stanescu
2416 147 Adrian Georgescu
>The hostname of the machine from which the Bonjour neighbour registered its contact address.
2417
  
2418
>+_uri_+:
2419 119 Luci Stanescu
2420 147 Adrian Georgescu
>The contact URI of the Bonjour neighbour, as a @FrozenSIPURI@ object.
2421
  
2422
>+_timestamp_+:
2423 119 Luci Stanescu
2424 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2425 119 Luci Stanescu
2426 147 Adrian Georgescu
*BonjourAccountDidUpdateNeighbour*
2427
>This notification is sent when an existing Bonjour neighbour has updates its published data.
2428
  
2429
>+_service_description_+:
2430 119 Luci Stanescu
2431 147 Adrian Georgescu
>BonjourServiceDescription object uniquely identifying this neighbour in the mDNS library.
2432
  
2433
>+_display_name_+:
2434 119 Luci Stanescu
2435 147 Adrian Georgescu
>The name of the neighbour as it is published.
2436
  
2437
>+_host_+:
2438 119 Luci Stanescu
2439 147 Adrian Georgescu
>The hostname of the machine from which the Bonjour neighbour registered its contact address.
2440
  
2441
>+_uri_+:
2442 119 Luci Stanescu
2443 147 Adrian Georgescu
>The contact URI of the Bonjour neighbour, as a @FrozenSIPURI@ object.
2444
  
2445
>+_timestamp_+:
2446 119 Luci Stanescu
2447 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2448 119 Luci Stanescu
2449 147 Adrian Georgescu
*BonjourAccountDidRemoveNeighbour*
2450
>This notification is sent when a Bonjour neighbour unregisters.
2451
  
2452
>+_service_description_+:
2453 119 Luci Stanescu
2454 147 Adrian Georgescu
>The BonjourServiceDescription object, which uniquely identifies a neighbour, that got unregistered.
2455 119 Luci Stanescu
2456 147 Adrian Georgescu
*BonjourAccountDiscoveryDidFail*
2457
>This notification is sent once per transport when the Bonjour account has failed to perform the discovery process for the indicated transport.
2458
  
2459
>+_reason_+:
2460 119 Luci Stanescu
2461 147 Adrian Georgescu
>String defining the reason of the failure.
2462
  
2463
>+_transport_+:
2464 119 Luci Stanescu
2465 147 Adrian Georgescu
>String specifying the transport for which the discovery failed.
2466
  
2467
>+_timestamp_+:
2468 119 Luci Stanescu
2469 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2470 119 Luci Stanescu
2471 147 Adrian Georgescu
*BonjourAccountDiscoveryFailure*
2472
>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.
2473
  
2474
>+_error_+:
2475
2476
>String defining the error of the failure.
2477
  
2478
>+_transport_+:
2479
2480
>String specifying the transport for which the neighbour resoution failed.
2481
  
2482
>+_timestamp_+:
2483
2484
>A @datetime.datetime@ object indicating when the notification was sent.
2485
2486
*BonjourAccountRegistrationDidEnd*
2487
>This notification is sent once per transport when the Bonjour account unregisters its contact address for the indicated transport using mDNS.
2488
  
2489
>+_transport_+:
2490
2491
>String specifying the transport for which the registration ended.
2492
  
2493
>+_timestamp_+:
2494
2495
>A @datetime.datetime@ object indicating when the notification was sent.
2496
2497
*BonjourAccountRegistrationDidFail*
2498
>This notification is sent once per transport when the Bonjour account fails to register its contact address for the indicated transport using mDNS.
2499
  
2500
>+_reason_+:
2501
2502
>A human readable error message.
2503
  
2504
>+_transport_+:
2505
2506
>String specifying the transport for which the registration failed.
2507
  
2508
>+_timestamp_+:
2509
2510
>A @datetime.datetime@ object indicating when the notification was sent.
2511
2512
*BonjourAccountRegistrationUpdateDidFail*
2513
>This notification is sent once per transport when the Bonjour account fails to update its data for the indicated transport using mDNS.
2514
  
2515
>+_reason_+:
2516
2517
>A human readable error message.
2518
  
2519
>+_transport_+:
2520
2521
>String specifying the transport for which the registration update failed.
2522
  
2523
>+_timestamp_+:
2524
2525
>A @datetime.datetime@ object indicating when the notification was sent.
2526
2527
*BonjourAccountRegistrationDidSucceed*
2528
>This notification is sent once per transport when the Bonjour account successfully registers its contact address for the indicated transport using mDNS.
2529
  
2530
>+_name_+:
2531
2532
>The contact address registered.
2533
  
2534
>+_transport_+:
2535
2536
>String specifying the transport for which the registration succeeded.
2537
  
2538
>+_timestamp_+:
2539
2540
>A @datetime.datetime@ object indicating when the notification was sent.
2541
2542
*BonjourAccountWillInitateDiscovery*
2543
>This notification is sent when the Bonjour account is about to start the discovery process for the indicated transport.
2544
  
2545
>+_transport_+:
2546
2547
>String specifying the transport for which the discovery will be started.
2548
  
2549
>+_timestamp_+:
2550
2551 1 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
2552 147 Adrian Georgescu
2553
  *BonjourAccountWillRegister*
2554
>This notification is sent just before the Bonjour account starts the registering process for the indicated transport.
2555 1 Adrian Georgescu
  
2556 147 Adrian Georgescu
>+_transport_+:
2557
>String specifying the transport for which the registration will be started.
2558 1 Adrian Georgescu
>+_timestamp_+:
2559 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
2560 147 Adrian Georgescu
2561
*CFGSettingsObjectDidChange*
2562
>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 [[SipConfigurationAPI#SettingsObjectNotifications|SettingsObject Notifications]].
2563
>+_timestamp_+:
2564 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
2565 147 Adrian Georgescu
2566
*SIPAccountWillActivate*
2567
>This notification is sent when the @BonjourAccount@ is about to be activated, but before actually performing any activation task. See @SIPAccountDidActivate@ for more detail.
2568
  
2569
>+_timestamp_+:
2570 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
2571 147 Adrian Georgescu
2572
*SIPAccountDidActivate*
2573
>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.
2574
  
2575
>+_timestamp_+:
2576 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
2577 147 Adrian Georgescu
2578
*SIPAccountWillDeactivate*
2579
>This notification is sent when the @BonjourAccount@ is about to be deactivated, but before performing any deactivation task. See @SIPAccountDidDeactivate@ for more detail.
2580
>+_timestamp_+:
2581 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
2582 147 Adrian Georgescu
2583
*SIPAccountDidDeactivate*
2584
>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@.
2585
>+_timestamp_+:
2586 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
2587 147 Adrian Georgescu
2588
2589
2590
h2. Audio
2591
2592
2593
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:
2594
* IAudioPort: an interface describing an object capable of producing and/or consuming audio data.
2595
* AudioDevice: an object conforming to the IAudioPort interface which describes a physical audio device.
2596
* AudioBridge: a collection of objects conforming to IAudioPort which connects all of them in a full mesh.
2597
* WavePlayer: an object conforming to the IAudioPort interface which can playback the audio data from a @.wav@ file.
2598
* WaveRecorder: an object conforming to the IAudioPort interface which can record audio data to a @.wav@ file.
2599
2600
2601
h3. IAudioPort
2602
2603
2604 119 Luci Stanescu
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.
2605
2606
2607 147 Adrian Georgescu
h4. attributes
2608 119 Luci Stanescu
2609
2610
2611 147 Adrian Georgescu
*mixer*
2612
>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.
2613 119 Luci Stanescu
2614 147 Adrian Georgescu
*consumer_slot*
2615
>An integer representing the slot (see [[SipCoreApiDocumentation#AudioMixer|AudioMixer]]) which this object uses to consume audio data, or @None@ if this object is not a consumer.
2616
2617
*producer_slot*
2618
>An integer representing the slot (see [[SipCoreApiDocumentation#AudioMixer|AudioMixer]]) which this object uses to produce audio data, or @None@ if this object is not a producer.
2619
2620
2621
h4. notifications
2622
2623 119 Luci Stanescu
 
2624
2625 147 Adrian Georgescu
*AudioPortDidChangeSlots*
2626
>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.
2627
  
2628
consumer_slot_changed:
2629 119 Luci Stanescu
2630 147 Adrian Georgescu
>A bool indicating whether the consumer slot was changed.
2631
  
2632
producer_slot_changed:
2633 119 Luci Stanescu
2634 147 Adrian Georgescu
>A bool indicating whether the producer slot was changed.
2635
  
2636
old_consumer_slot:
2637 119 Luci Stanescu
2638 147 Adrian Georgescu
>The old slot for consuming audio data. Only required if consumer_slot_changed is @True@.
2639
  
2640
new_consumer_slot:
2641 119 Luci Stanescu
2642 147 Adrian Georgescu
>The new slot for consuming audio data. Only required if consumer_slot_changed is @True@.
2643
  
2644
old_producer_slot:
2645 119 Luci Stanescu
2646 147 Adrian Georgescu
>The old slot for producing audio data. Only required if producer_slot_changed is @True@.
2647
  
2648
new_producer_slot:
2649 119 Luci Stanescu
2650 147 Adrian Georgescu
>The new slot for producing audio data. Only required if producer_slot_changed is @True@.
2651 119 Luci Stanescu
2652
2653 147 Adrian Georgescu
h3. AudioDevice
2654 119 Luci Stanescu
2655
2656 147 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.
2657 119 Luci Stanescu
2658
2659 147 Adrian Georgescu
h4. methods
2660 119 Luci Stanescu
2661
2662
2663 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *mixer*, *input_muted*=@False@, *output_muted*=@False@):
2664
>Instantiates a new AudioDevice which represents the physical device associated with the specified @AudioMixer@.
2665
  
2666
mixer:
2667 119 Luci Stanescu
2668 147 Adrian Georgescu
>The @AudioMixer@ whose physical device this object represents.
2669
  
2670
input_muted:
2671 119 Luci Stanescu
2672 147 Adrian Georgescu
>A boolean which indicates whether this object should act as a producer of audio data.
2673
  
2674
output_muted:
2675 119 Luci Stanescu
2676 147 Adrian Georgescu
>A boolean which indicates whether this object should act as a consumer of audio data.
2677 119 Luci Stanescu
2678
2679 147 Adrian Georgescu
h4. attributes
2680 119 Luci Stanescu
2681
2682
2683 147 Adrian Georgescu
*input_muted*
2684
>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.
2685 119 Luci Stanescu
2686 147 Adrian Georgescu
*output_muted*
2687
>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.
2688 119 Luci Stanescu
2689
2690 147 Adrian Georgescu
h3. AudioBridge
2691 119 Luci Stanescu
2692
2693 147 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@.
2694
> Note: although this is not enforced, there should never be any cycles when connecting @AudioBridges@.
2695 119 Luci Stanescu
2696
2697 147 Adrian Georgescu
h4. methods
2698 119 Luci Stanescu
2699
2700
2701 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *mixer*)
2702
>Instantiate a new @AudioBridge@ which uses the specified @AudioMixer@ for mixing.
2703 119 Luci Stanescu
2704 147 Adrian Georgescu
*add*(_self_, *port*)
2705
>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.
2706 119 Luci Stanescu
2707 147 Adrian Georgescu
*remove*(_self_, *port*)
2708
>Remove a port from this @AudioBridge@. The port must have previously been added to the @AudioBridge@, otherwise a @ValueError@ is raised.
2709 119 Luci Stanescu
2710
2711 147 Adrian Georgescu
h3. WavePlayer
2712 119 Luci Stanescu
2713
2714 147 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.
2715 1 Adrian Georgescu
2716
2717 147 Adrian Georgescu
h4. methods
2718 1 Adrian Georgescu
2719
2720
2721 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *mixer*, *filename*, *volume*=@100@, *loop_count*=@1@, *pause_time*=@0@, *initial_play*=@True@)
2722
>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.
2723
  
2724
mixer:
2725 1 Adrian Georgescu
2726 147 Adrian Georgescu
>The @AudioMixer@ this object is connected to.
2727
  
2728
filename:
2729 1 Adrian Georgescu
2730 147 Adrian Georgescu
>The full path to the @.wav@ file from which audio data is to be read.
2731
  
2732
volume:
2733 1 Adrian Georgescu
2734 147 Adrian Georgescu
>The volume at which the file should be played.
2735
  
2736
loop_count:
2737 1 Adrian Georgescu
2738 147 Adrian Georgescu
>The number of times the file should be played, or @0@ for infinity.
2739
  
2740
pause_time:
2741 1 Adrian Georgescu
2742 147 Adrian Georgescu
>How many seconds to wait between successive plays of the file. 
2743
  
2744
initial_play:
2745 1 Adrian Georgescu
2746 147 Adrian Georgescu
>Whether or not the file to play once the @WavePlayer@ is started, or to wait @pause_time@ seconds before the first play.
2747 1 Adrian Georgescu
2748 147 Adrian Georgescu
*start*(_self_)
2749
>Start playing the @.wav@ file.
2750 1 Adrian Georgescu
2751 147 Adrian Georgescu
*stop*(_self_)
2752
>Stop playing the @.wav@ file immediately.
2753 1 Adrian Georgescu
2754 147 Adrian Georgescu
*play*(_self_)
2755
>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.
2756 1 Adrian Georgescu
2757
2758 147 Adrian Georgescu
h4. attributes
2759 1 Adrian Georgescu
2760
2761
2762 147 Adrian Georgescu
*is_active*
2763
>A boolean indicating whether or not this @WavePlayer@ is currently playing.
2764 1 Adrian Georgescu
2765
2766 147 Adrian Georgescu
h4. notifications
2767 1 Adrian Georgescu
2768
2769 147 Adrian Georgescu
2770
*WavePlayerDidStart*
2771
>This notification is sent when the @WavePlayer@ starts playing the file the first time after the @start()@ method has been called.
2772
  
2773
timestamp:
2774
2775
>A @datetime.datetime@ object indicating when the notification was sent.
2776
2777
*WavePlayerDidEnd*
2778
>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.
2779
  
2780
timestamp:
2781
2782
>A @datetime.datetime@ object indicating when the notification was sent.
2783
2784
*WavePlayerDidFail*
2785
>This notification is sent when the @WavePlayer@ is not capable of playing the @.wav@ file.
2786
  
2787
timestamp:
2788
2789
>A @datetime.datetime@ object indicating when the notification was sent.
2790
  
2791
error:
2792
2793
>The exception raised by the @WaveFile@ which identifies the cause for not being able to play the @.wav@ file.
2794
2795
2796
h3. WaveRecorder
2797
2798
2799
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.
2800
2801
2802
h4. methods
2803
2804
2805
2806
*<notextile>__init__</notextile>*(_self_, *mixer*, *filename*)
2807
>Instantiate a new @WaveRecorder@.
2808
  
2809
mixer:
2810
2811
>The @AudioMixer@ this @WaveRecorder@ is connected to.
2812
  
2813
filename:
2814
2815
>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.
2816
2817
*start*(_self_)
2818
>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.
2819
2820
*stop*(_self_)
2821
>Stop consuming audio data and close the @.wav@ file.
2822
2823
2824
h4. attributes
2825
2826
2827
2828
*is_active*
2829
>A boolean indicating whether or not this @WaveRecorder@ is currently recording audio data.
2830
2831
2832
2833
h2. Conference
2834
2835
2836
Conference support is implemented in the @sipsimple.conference@ module. Currently, only audio conferencing is supported.
2837
2838
2839
h3. AudioConference
2840
2841
2842
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.
2843
2844
2845
h4. methods
2846
2847
2848
2849
*<notextile>__init__</notextile>*(_self_)
2850
>Instantiates a new @AudioConference@ which is ready to contain @AudioStream@ objects.
2851
2852
*add*(_self_, *stream*)
2853
>Add the specified @AudioStream@ object to the conference.
2854
2855
*remove*(_self_, *stream*)
2856
>Removes the specified @AudioStream@ object from the conference. Raises a @ValueError@ if the stream is not part of the conference.
2857
2858
*hold*(_self_)
2859
>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.
2860
2861
*unhold*(_self_)
2862
>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.
2863
2864
2865
h4. attributes
2866
2867
2868
2869
*bridge*
2870
>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@.
2871
2872
*on_hold*
2873
>A boolean indicating whether or not the conference is "on hold".
2874
2875
*streams*
2876
>The list of streams which are part of this conference. The application must not manipulate this list in any way.
2877
2878
2879
2880
h2. XCAP support
2881
2882
2883
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
2884 1 Adrian Georgescu
which can be managed by means of this module are:
2885 147 Adrian Georgescu
* *contact list*, by means of the @resource-lists@ and @rls-services@ XCAP applications
2886
* *presence policies*, by means of the @org.openmobilealliance.pres-rules@ or @pres-rules@ XCAP applications
2887
* *dialoginfo policies*, by means of the @org.openxcap.dialog-rules@ XCAP application
2888
* *status icon*, by means of the @org.openmobilealliance.pres-content@ XCAP application
2889
* *offline status*, by means of the @pidf-manipulation@ XCAP application
2890 1 Adrian Georgescu
2891
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
2892
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
2893
the resources stored on the XCAP server.
2894
2895
2896 147 Adrian Georgescu
h3. Contact
2897 1 Adrian Georgescu
2898
2899 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
2900 1 Adrian Georgescu
2901 147 Adrian Georgescu
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@,
2902
@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
2903
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.
2904 1 Adrian Georgescu
2905
2906 147 Adrian Georgescu
h4. attributes
2907 1 Adrian Georgescu
2908
2909 147 Adrian Georgescu
*name*
2910
>A human-readable name which can be associated with the contact. This is stored using the @display-name@ standard @resource-lists@ element.
2911 1 Adrian Georgescu
2912 147 Adrian Georgescu
*uri*
2913
>The uniquely identifying URI.
2914
2915
*group*
2916
>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@
2917
>document, as defined by OMA. The group of a contact is the first @display-name@ of an ancestor list which contains the contact information.
2918
2919
*subscribe_to_presence*
2920
>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
2921
  @presence@ as one of the packages. Thus, a contact with this flag set is guaranteed to be referenced by an RLS service.
2922
2923
*subscribe_to_dialoginfo*
2924
>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
2925
  @dialog@ as one of the packages. Thus, a contact with this flag set is guaranteed to be refereneced by an RLS service.
2926
2927
*presence_policies*
2928
>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
2929 1 Adrian Georgescu
  (through an identity condition) or indirectly through resource lists (using the OMA external-list common policy extension).
2930
2931 147 Adrian Georgescu
*dialoginfo_policies*
2932
>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.
2933 1 Adrian Georgescu
2934 147 Adrian Georgescu
*attributes*
2935
>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
2936
>extension to resource-lists.
2937 1 Adrian Georgescu
2938
2939 147 Adrian Georgescu
h4. methods
2940 1 Adrian Georgescu
2941
2942 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *name*, *uri*, *group*, ***attributes*)
2943
>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@.
2944 1 Adrian Georgescu
2945
2946
2947 147 Adrian Georgescu
h3. Service
2948 1 Adrian Georgescu
2949
2950 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
2951 1 Adrian Georgescu
2952 147 Adrian Georgescu
A @Service@ represents a URI managed by a Resource List Server (RLS). Subscriptions to this URI will be handled by the RLS.
2953 1 Adrian Georgescu
2954
2955 147 Adrian Georgescu
h4. attributes
2956 1 Adrian Georgescu
2957
2958 147 Adrian Georgescu
*uri*
2959
>The URI which can be used to access a service provided by the RLS.
2960 1 Adrian Georgescu
2961 147 Adrian Georgescu
*packages*
2962
>A list of strings containing the SIP events which can be subscribed for to the URI.
2963 1 Adrian Georgescu
2964 147 Adrian Georgescu
*entries*
2965
>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.
2966 1 Adrian Georgescu
2967
2968 147 Adrian Georgescu
h4. methods
2969 1 Adrian Georgescu
2970
2971 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *uri*, *packages*, *entries*=@None@)
2972
>Initializes a new @Service@ instance.
2973
2974
2975
2976
h3. Policy
2977
2978
2979
Implemented in [browser:sipsimple/xcap/+init+.py]
2980
2981
@Policy@ is the base class for @PresencePolicy@ and @DialoginfoPolicy@. It describes the attributes common to both.
2982
2983
2984
h4. attributes
2985
2986
2987
*id*
2988
>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.
2989
2990
*action*
2991
>A string having one of the values @"allow"@, @"confirm"@, @"polite-block"@ or @"block"@.
2992
2993
*validity*
2994
>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:
2995
  <pre>
2996 1 Adrian Georgescu
  from datetime import datetime, timedelta
2997
  now = datetime.now()
2998
  one_hour = timedelta(seconds=3600)
2999
  one_day = timedelta(days=1)
3000
  validity = [(now-one_hour, now+one_hour), (now+one_day-one_hour, now+one_day+one_hour)]
3001 147 Adrian Georgescu
</pre>
3002 1 Adrian Georgescu
3003 147 Adrian Georgescu
*sphere*
3004
>Either @None@ or a string representing the sphere of presentity when this policy applies.
3005 1 Adrian Georgescu
3006 147 Adrian Georgescu
*multi_identity_conditions*
3007
>Either @None@ or a list of @CatchAllCondition@ or @DomainCondition@ objects as defined below. This is used to apply this policy to multiple users.
3008 1 Adrian Georgescu
3009
3010 147 Adrian Georgescu
h4. methods
3011 1 Adrian Georgescu
3012
3013 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *id*, *action*, *name*=@None@, *validity*=@None@, *sphere*=@None@, *multi_identity_conditions*=@None@)
3014
>Initializes a new @Policy@ instance.
3015 1 Adrian Georgescu
3016 147 Adrian Georgescu
*check_validity*(_self_, *timestamp*, *sphere*=@Any@)
3017
>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.
3018 1 Adrian Georgescu
3019
3020
3021 147 Adrian Georgescu
h3. CatchAllCondition
3022 1 Adrian Georgescu
3023
3024 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
3025 1 Adrian Georgescu
3026 147 Adrian Georgescu
@CatchAllCondition@ represents a condition which matches any user, but which can have some exceptions.
3027 1 Adrian Georgescu
3028
3029 147 Adrian Georgescu
h4. attributes
3030 1 Adrian Georgescu
3031
3032 147 Adrian Georgescu
*exceptions*
3033
>A list containing @DomainException@ or @UserException@ objects to define when this condition does not apply.
3034 1 Adrian Georgescu
3035
3036 147 Adrian Georgescu
h4. methods
3037 1 Adrian Georgescu
3038
3039 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *exceptions*=@None@)
3040
>Initializes a new @CatchAllCondition@ instance.
3041 1 Adrian Georgescu
3042
3043
3044 147 Adrian Georgescu
h3. DomainCondition
3045 1 Adrian Georgescu
3046
3047 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
3048 1 Adrian Georgescu
3049 147 Adrian Georgescu
@DomainCondition@ represents a condition which matches any user within a specified domain, but which can have some exceptions.
3050 1 Adrian Georgescu
3051
3052 147 Adrian Georgescu
h4. attributes
3053 1 Adrian Georgescu
3054
3055 147 Adrian Georgescu
*domain*
3056
>A string containing the domain for which this condition applies.
3057 1 Adrian Georgescu
3058 147 Adrian Georgescu
*exceptions*
3059
>A list containing @UserEception@ objects to define when this condition does not apply.
3060 1 Adrian Georgescu
3061
3062
3063 147 Adrian Georgescu
h4. methods
3064 1 Adrian Georgescu
3065
3066 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *domain*, *exceptions*=@None@)
3067
>Initializes a new @DomainCondition@ instance.
3068 1 Adrian Georgescu
3069
3070
3071 147 Adrian Georgescu
h3. DomainException
3072 1 Adrian Georgescu
3073
3074 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
3075 1 Adrian Georgescu
3076 147 Adrian Georgescu
@DomainException@ is used as an exception for a @CatchAllCondition@ which excludes all users within a specified domain.
3077 1 Adrian Georgescu
3078
3079 147 Adrian Georgescu
h4. attributes
3080
3081
3082
*domain*
3083
>A string containing the domain which is to be excluded from the @CatchAllCondition@ containing this object as an exception.
3084
3085
3086
3087
h4. methods
3088
3089
3090
*<notextile>__init__</notextile>*(_self_, *domain*)
3091
>Initializes a new @DomainException@ instance.
3092
3093
3094
3095
h3. UserException
3096
3097
3098
Implemented in [browser:sipsimple/xcap/+init+.py]
3099
3100
@UserException@ is used as an exception for either a @CatchAllCondition@ or a @DomainCondition@ and excludes a user identified by an URI.
3101
3102
3103
h4. attributes
3104
3105
3106
*uri*
3107
>A string containing the URI which is to be excluded from the @CatchAllCondition@ or @DomainCondition@ containing this object as an exception.
3108
3109
3110
3111
h4. methods
3112
3113
3114
*<notextile>__init__</notextile>*(_self_, *uri*)
3115
>Initializes a new @UserException@ instance.
3116
3117
3118
3119
h3. PresencePolicy
3120
3121
3122
Implemented in [browser:sipsimple/xcap/+init+.py]
3123
3124
A @PresencePolicy@ represents either a @org.openmobilealliance.pres-rules@ or @pres-rules@ rule. It subclasses @Policy@ and inherits its attributes, but defines additional
3125 1 Adrian Georgescu
attributes corresponding to the transformations which can be specified in a rule.
3126
3127
3128 147 Adrian Georgescu
h4. attributes
3129 1 Adrian Georgescu
3130
3131 147 Adrian Georgescu
 All of the following attributes only make sense for a policy having a @"allow"@ action.
3132 1 Adrian Georgescu
3133 147 Adrian Georgescu
*provide_devices*
3134
>Either @sipsimple.util.All@, or a list of @Class@, @OccurenceID@ or @DeviceID@ objects as defined below.
3135 1 Adrian Georgescu
3136 147 Adrian Georgescu
*provide_persons*
3137
>Either @sipsimple.util.All@, or a list of @Class@ or @OccurenceID@ objects as defined below.
3138 1 Adrian Georgescu
3139 147 Adrian Georgescu
*provide_services*
3140
>Either @sipsimple.util.All@, or a list of @Class@, @OccurenceID@, @ServiceURI@ or @ServiceURIScheme@ objects as defined below.
3141 1 Adrian Georgescu
3142 147 Adrian Georgescu
*provide_activities*
3143
>Either @None@ (if the transformation is not be specified) or a boolean.
3144 1 Adrian Georgescu
3145 147 Adrian Georgescu
*provide_class*
3146
>Either @None@ (if the transformation is not be specified) or a boolean.
3147 1 Adrian Georgescu
3148 147 Adrian Georgescu
*provide_device_id*
3149
>Either @None@ (if the transformation is not be specified) or a boolean.
3150 1 Adrian Georgescu
3151 147 Adrian Georgescu
*provide_mood*
3152
>Either @None@ (if the transformation is not be specified) or a boolean.
3153 1 Adrian Georgescu
3154 147 Adrian Georgescu
*provide_place_is*
3155
>Either @None@ (if the transformation is not be specified) or a boolean.
3156 1 Adrian Georgescu
3157 147 Adrian Georgescu
*provide_place_type*
3158
>Either @None@ (if the transformation is not be specified) or a boolean.
3159 1 Adrian Georgescu
3160 147 Adrian Georgescu
*provide_privacy*
3161
>Either @None@ (if the transformation is not be specified) or a boolean.
3162 1 Adrian Georgescu
3163 147 Adrian Georgescu
*provide_relationship*
3164
>Either @None@ (if the transformation is not be specified) or a boolean.
3165 1 Adrian Georgescu
3166 147 Adrian Georgescu
*provide_status_icon*
3167
>Either @None@ (if the transformation is not be specified) or a boolean.
3168 1 Adrian Georgescu
3169 147 Adrian Georgescu
*provide_sphere*
3170
>Either @None@ (if the transformation is not be specified) or a boolean.
3171 1 Adrian Georgescu
3172 147 Adrian Georgescu
*provide_time_offset*
3173
>Either @None@ (if the transformation is not be specified) or a boolean.
3174 1 Adrian Georgescu
3175 147 Adrian Georgescu
*provide_user_input*
3176
>Either @None@ (if the transformation is not be specified) or one of the strings @"false"@, @"bare"@, @"thresholds"@, @"full"@.
3177 1 Adrian Georgescu
3178 147 Adrian Georgescu
*provide_unknown_attributes*
3179
>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).
3180 1 Adrian Georgescu
3181 147 Adrian Georgescu
*provide_all_attributes*
3182
>Either @None@ (if the transformation is not be specified) or a boolean.
3183 1 Adrian Georgescu
3184
3185 147 Adrian Georgescu
h4. methods
3186 1 Adrian Georgescu
3187
3188 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *id*, *action*, *name*=@None@, *validity*=@None@, *sphere*=@None@, *multi_identity_conditions*=@None@)
3189
>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@.
3190
3191
3192
3193
h3. DialoginfoPolicy
3194
3195
3196
Implemented in [browser:sipsimple/xcap/+init+.py]
3197
3198
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
3199 1 Adrian Georgescu
has an identical API.
3200
3201
3202
3203 147 Adrian Georgescu
h3. Icon
3204 1 Adrian Georgescu
3205
3206 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
3207 1 Adrian Georgescu
3208 147 Adrian Georgescu
An @Icon@ instance represents a status icon stored using the @org.openmobilealliance.pres-content@ application.
3209 1 Adrian Georgescu
3210
3211 147 Adrian Georgescu
h4. attributes
3212 1 Adrian Georgescu
3213
3214 147 Adrian Georgescu
*data*
3215
>The binary data of the image, as  a string.
3216 1 Adrian Georgescu
3217 147 Adrian Georgescu
*mime_type*
3218
>The MIME type of the image, one of @image/jpeg@, @image/gif@ or @image/png@.
3219 1 Adrian Georgescu
3220 147 Adrian Georgescu
*description*
3221
>An optional description of the icon.
3222 1 Adrian Georgescu
3223 147 Adrian Georgescu
*location*
3224
>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
3225
>responses, that is used otherwise the XCAP URI of the icon is used.
3226 1 Adrian Georgescu
3227
3228 147 Adrian Georgescu
h4. methods
3229 1 Adrian Georgescu
3230
3231 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *data*, *mime_type*, *description*=@None@, *location*=@None@)
3232
>Initializes a new @Icon@ instance.
3233 1 Adrian Georgescu
3234
3235
3236 147 Adrian Georgescu
h3. OfflineStatus
3237 1 Adrian Georgescu
3238
3239 147 Adrian Georgescu
Implemented in [browser:sipsimple/xcap/+init+.py]
3240 1 Adrian Georgescu
3241 147 Adrian Georgescu
An @OfflineStatus@ instance represents data stored using the @pidf-manipulation@ application.
3242 1 Adrian Georgescu
3243
3244 147 Adrian Georgescu
h4. attributes
3245 1 Adrian Georgescu
3246 147 Adrian Georgescu
3247
*activity*
3248
>A string representing an activity within a @person@ element.
3249
3250
*note*
3251
>A string stored as a note within a @person@ element.
3252
3253
3254
h4. methods
3255
3256
3257
*<notextile>__init__</notextile>*(_self_, *activity*=@None@, *note*=@Note@)
3258
>Initializes a new @OfflineStatus@ instance.
3259
3260
3261
3262
h3. XCAPManager
3263
3264
3265
Implemented in [browser:sipsimple/xcap/+init+.py]
3266
3267
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:
3268
3269
!{ align=center}xcap-manager-state.png!
3270
3271
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,
3272
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
3273
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
3274 1 Adrian Georgescu
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
3275 147 Adrian Georgescu
@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
3276 1 Adrian Georgescu
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
3277 147 Adrian Georgescu
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
3278
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@
3279
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.
3280 1 Adrian Georgescu
3281 147 Adrian Georgescu
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
3282 1 Adrian Georgescu
one.
3283
3284 147 Adrian Georgescu
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
3285
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.
3286 1 Adrian Georgescu
3287 147 Adrian Georgescu
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
3288
@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
3289 1 Adrian Georgescu
is not modified.
3290
3291
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
3292
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
3293
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
3294
of the document.
3295
3296
3297 147 Adrian Georgescu
h4. configuration
3298 1 Adrian Georgescu
3299
3300 147 Adrian Georgescu
*Account.id*, *Account.auth.username*, *Account.auth.password*
3301
>These are used both for the @xcap-diff@ subscription and the XCAP server connection. 
3302
3303
*Account.sip.subscribe_interval*
3304
>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.
3305
3306
*Account.xcap.xcap_root*
3307
>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
3308
>domain. The result is interpreted as being an XCAP root. Example record for account alice@example.org:
3309
  <pre>
3310 1 Adrian Georgescu
  xcap.example.org.    IN  TXT     "https://xcap.example.org/xcap-root"
3311 147 Adrian Georgescu
</pre>
3312 1 Adrian Georgescu
3313 147 Adrian Georgescu
*SIPSimpleSettings.sip.transport_list*
3314
>This controls the transports which can be used for the subscription.
3315 1 Adrian Georgescu
3316
3317 147 Adrian Georgescu
h4. methods
3318 1 Adrian Georgescu
3319
3320 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *account*)
3321
>Initializes an XCAPManager for the specified account.
3322 1 Adrian Georgescu
3323 147 Adrian Georgescu
*load*(_self_)
3324
>Allows the XCAPManager to the load its internal data from cache.
3325 1 Adrian Georgescu
3326 147 Adrian Georgescu
*start*(_self_)
3327
>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
3328
>thread.
3329 1 Adrian Georgescu
3330 147 Adrian Georgescu
*stop*(_self_)
3331
>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.
3332 1 Adrian Georgescu
3333 147 Adrian Georgescu
*start_transaction*(_self_)
3334
>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.
3335
>This does not have the same meaning as a relational database transaction, since there is no @rollback@ operation.
3336
3337
*commit_transaction*(_self_)
3338
>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
3339
>any effect if @start_transaction@ was not previously called.
3340
3341 1 Adrian Georgescu
 The following methods results in XCAP operations being queued on the journal:
3342
3343 147 Adrian Georgescu
*add_group*(_self_, *group*)
3344
>Add a contact group with the specified name.
3345 1 Adrian Georgescu
3346 147 Adrian Georgescu
*rename_group*(_self_, *old_name*, *new_name*)
3347
>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.
3348 1 Adrian Georgescu
3349 147 Adrian Georgescu
*remove_group*(_self_, *group*)
3350
>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.
3351 1 Adrian Georgescu
3352 147 Adrian Georgescu
*add_contact*(_self_, *contact*)
3353
>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
3354
>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@,
3355
  @wp_prs_block_anonymous@, @wp_prs_allow_own@) is ignored.
3356 1 Adrian Georgescu
3357 147 Adrian Georgescu
*update_contact*(_self_, *contact*, ***attributes*)
3358
>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
3359
>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@,
3360
  @wp_prs_allow_own@) is ignored. The URI of a contact can be changed by specified the keyword argument @uri@ with the new value.
3361 1 Adrian Georgescu
3362 147 Adrian Georgescu
*remove_contact*(_self_, *contact*)
3363
>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.
3364 1 Adrian Georgescu
3365 147 Adrian Georgescu
*add_presence_policy*(_self_, *policy*)
3366
>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
3367
>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
3368
>are some multi_identity_conditions), a new one will be automatically generated.
3369 1 Adrian Georgescu
3370 147 Adrian Georgescu
*update_presence_policy*(_self_, *policy*, ***attributes*)
3371
>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.
3372
>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
3373
>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.
3374 1 Adrian Georgescu
3375 147 Adrian Georgescu
*remove_presence_policy*(_self_, *policy*)
3376
>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
3377
>anything. Some standard OMA policies (@wp_prs_unlisted@, @wp_prs_allow_unlisted@, @wp_prs_block_anonymous@, @wp_prs_allow_own@, @wp_prs_grantedcontacts@,
3378
  @wp_prs_blockedcontacts@) cannot be removed.
3379 1 Adrian Georgescu
3380 147 Adrian Georgescu
*add_dialoginfo_policy*(_self_, *policy*)
3381
>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
3382
>not specified, one will be automatically generated (recommended).
3383 1 Adrian Georgescu
3384 147 Adrian Georgescu
*update_dialoginfo_policy*(_self_, *policy*, ***attributes*)
3385
>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
3386
>argument. If such a policy does not exist and there is sufficient information about the policy, it is added.
3387 1 Adrian Georgescu
3388 147 Adrian Georgescu
*remove_dialoginfo_policy*(_self_, *policy*)
3389
>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
3390
>anything.
3391 1 Adrian Georgescu
3392 147 Adrian Georgescu
*set_status_icon*(_self_, *icon*)
3393
>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
3394
  @image/jpeg@. If the argument is @None@, the status icon is deleted.
3395 1 Adrian Georgescu
3396 147 Adrian Georgescu
*set_offline_status*(_self_, *status*)
3397
>Sets the offline status using the information from the @OfflineStatus@ object specified. If the argument is @None@, the offline status document is deleted.
3398 1 Adrian Georgescu
3399
3400 147 Adrian Georgescu
h4. notifications
3401 1 Adrian Georgescu
3402
3403 147 Adrian Georgescu
*XCAPManagerWillStart*
3404
>This notification is sent just after calling the @start@ method.
3405
  
3406
timestamp:
3407 1 Adrian Georgescu
3408 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
3409 1 Adrian Georgescu
3410 147 Adrian Georgescu
*XCAPManagerDidStart*
3411
>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
3412
>any of these operations were successful, as the XCAPManager will retry them continuously should they fail.
3413
  
3414
timestamp:
3415 1 Adrian Georgescu
3416 147 Adrian Georgescu
>A @datetime.datetime@ object indicating when the notification was sent.
3417 1 Adrian Georgescu
3418 147 Adrian Georgescu
*XCAPManagerWillEnd*
3419
>This notification is sent just after calling the @stop@ method.
3420
  
3421
timestamp:
3422
3423
>A @datetime.datetime@ object indicating when the notification was sent.
3424
3425
*XCAPManagerDidEnd*
3426
>This notification is sent when the XCAPManager has stopped performing any tasks. This also means that any active @xcap-diff@ subscription has been terminated.
3427
  
3428
timestamp:
3429
3430
>A @datetime.datetime@ object indicating when the notification was sent.
3431
3432
*XCAPManagerDidDiscoverServerCapabilities*
3433
>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
3434
>information about the server's capabilities (obtained using the @xcap-caps@ application).
3435
  
3436
contactlist_supported:
3437
3438
>A boolean indicating the support of documents needed for contact management (@resource-lists@ and @rls-services@).
3439
  
3440
presence_policies_supported:
3441
3442
>A boolean indicating the support of documents needed for presence policy management (@org.openmobilealliance.pres-rules@ or @pres-rules@).
3443
  
3444
dialoginfo_policies_supported:
3445
3446
>A boolean indicating the support of documents needed for dialoginfo policy management (@org.openxcap.dialog-rules@).
3447
  
3448
status_icon_supported:
3449
3450
>A boolean indicating the support of documents needed for status icon management (@org.openmobilealliance.pres-content@).
3451
  
3452
offline_status_supported:
3453
3454
>A boolean indicating the support of documents needed for offline status management (@pidf-manipulation@).
3455
  
3456
timestamp:
3457
3458
>A @datetime.datetime@ object indicating when the notification was sent.
3459
3460
*XCAPManagerDidReloadData*
3461
>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.
3462
  
3463
contacts:
3464
3465
>A list of @Contact@ objects.
3466
  
3467
groups:
3468
3469
>A list of strings.
3470
  
3471
services:
3472
3473
>A list of @Service@ objects.
3474
  
3475
presence_policies:
3476
3477
>A list of @PresencePolicy@ objects.
3478
  
3479
dialoginfo_policies:
3480
3481
>A list of @DialoginfoPolicy@ objects.
3482
  
3483
status_icon:
3484
3485
>A @StatusIcon@ object if one is stored, @None@ otherwise.
3486
  
3487
offline_status:
3488
3489
>A @OfflineStatus@ object if offline status information is stored, @None@ otherwise.
3490
  
3491
timestamp:
3492
3493
>A @datetime.datetime@ object indicating when the notification was sent.
3494
3495
*XCAPManagerDidChangeState*
3496
>This notification is sent when the XCAPManager transitions from one state to another.
3497
  
3498
prev_state:
3499
3500
>The old state of the XCAPManager, a string.
3501
  
3502
state:
3503
3504
>The new state of the XCAPManager, a string.
3505
  
3506
timestamp:
3507
3508
>A @datetime.datetime@ object indicating when the notification was sent.