IMAP Resource: handle disconnection before initial "OK" from server

Authored by dfaure on Apr 21 2018, 4:18 PM.

Description

IMAP Resource: handle disconnection before initial "OK" from server

1b79b4b in kimap makes connectionLost useful again, as the best way
to detect that we managed to connect (so the server actually exists and
is (or was) reachable) and then lost connection. Use that instead of the
state change to distinguish from the wrong hostname case (where we don't want to
retry, we'd loop forever doing that).

Test Plan: Expand existing unittest to test 3 different cases of connection lost,
all after the initial connect. The next method (shouldNotifyFailureToConnect)
ensures that the "wrong hostname" case still works.

Differential Revision: https://phabricator.kde.org/D12418