TODO
----

 - Use individual TCP/TLS transport per SIP account
 - Use individual TLS settings per account (CA, list, certificate and verify server)
 - After ICE neg is completed we must send re-INVITE with the chosen RTP candidates
 - Cannot retry a Call Transfer if it failed (invitation._transfer_usage is not reset) 
 - Modify Invitation/Request/Subscription to reset transport on request_uri
 - Application.py subscribes to notifications but doesn't remove them when it stops
 - Send notifications when local/remote party becomes focus
   SIPSessionLocalPartyIsFocus, SIPSessionRemotePartyIsFocus


Migrate from eventlib to gevent
-------------------------------

 * http://sdiehl.github.io/gevent-tutorial/
 * https://blog.gevent.org/2010/02/27/why-gevent/
 * http://groups.google.com/group/gevent/browse_thread/thread/7fca7230db0509f6


TODO Python version 2
---------------------

- If the SIP account password is changed on the server, then the client
  modifies some contact, xcap PUT will keep failing with 401 even after
  the password is reverted on the server. This will only be fixed by
  deactivating/reactivating the account or restarting the application.

- Warning header takes a code (300-399) a hostname (not user agent) and a
  message. Class allows any code (100-999) and we use engine.user_agent
  for the hostname where we use this header in session.py

- 202 is deprecated (see https://tools.ietf.org/html/rfc6665#page-43)

- After ICE negotiation completed we do not save state and later re-INVITEs
  can fail, we must send re-INVITE or UPDATE with chosen candidate

+ Allow resume of failed file transfers (a=file-range SDP attribute)

+ combine account.uri and account.contact into account.uri.aor and
  account.uri.contact. This will also remove the confusion between
  account.contact and account.contact_manager

+ change settings so they store changes in a thread local container
  which is made public (accessible for all threads) when save is called.
  This will make changes be atomic inside a thread (everything from 
  attribute changes up to the save operation is contained in the thread
  and will not mix with changes done in parallel from other threads).

+ there is a race condition that can prevent an account to start if it is
  created while the start method of SIPApplication runs and it passed the
  point where it called AccountManager.start. A quick workaround is to
  never create an account before SIPApplicationDidStart is posted

+ SIPApplication.start attempts to be restartable in case of errors, but
  there are cases where it may enter into a state where it will raise
  exceptions perpetually, even if the condition that led to the exception
  was fixed.

- allow deleting transport on SIPURI

- End a session while in accepting state (requires session serialization)

- Model file transfer after desktop sharing (use handlers on termination)
  have internal/external handlers (notifications based or file bridges)

- Use an ordered dict for keeping accounts in the AccountManager ?!?
  see http://code.activestate.com/recipes/576693/

- have higher level notifications on conference events

- Notification from SIPApplication when a transport is added/removed to the
  engine.

- SIPApplication should provide a list of supported transports that need to
  be used instead of the ones from settings because not everything enabled
  in settings may actually be available at runtime on the engine

- Build contacts on above notification instead of building them on the fly

- Ability to start stream deactivated / on-hold
    - VideoStream(direction='sendrecv') like MSRP?
    - Review stream API, s/deactivate/shutdown/ ?

- Open the camera at its native framerate
