Implement STARTTLS

Implement the IMAP STARTTLS command in RFC3501 6.2.1

      A [TLS] negotiation begins immediately after the CRLF at the end
      of the tagged OK response from the server.  Once a client issues a
      STARTTLS command, it MUST NOT issue further commands until a
      server response is seen and the [TLS] negotiation is complete.

      The server remains in the non-authenticated state, even if client
      credentials are supplied during the [TLS] negotiation.  This does
      not preclude an authentication mechanism such as EXTERNAL (defined
      in [SASL]) from using client identity determined by the [TLS]
      negotiation.

      Once [TLS] has been started, the client MUST discard cached
      information about server capabilities and SHOULD re-issue the
      CAPABILITY command.  This is necessary to protect against man-in-
      the-middle attacks which alter the capabilities list prior to
      STARTTLS.  The server MAY advertise different capabilities after
      STARTTLS.

+ move the SSL connection in MailTrasport to reopenTls so it can be
  reused.
+ mAddress to store the address of the current connection
+ CAPABILITY command support in ImapConnection. Send a query by
  queryCapability() The response will be stored in a set and can be
  checked by hasCapability().

Change-Id: I0beb1be088c720025a8e4ae07c0d230b619c2ce3
Fixes:27817101
(cherry picked from commit 9843724383c12ecdad69e529325278b8ebec5d17)
3 files changed