ImapResource: Cancel the current task if we disconnect while the login is ongoing.

Otherwise we may end up with a stuck startConnect task if the socket somehow disconnects during login.
do not call tagsReceieved unconditionally: check what we are fetching first

consolidates that code in a taskComplete() method to avoid code dupe
and similar future fubars
Merge remote-tracking branch 'kolab/kolab/integration/4.13.0' into kolab/integration/4.13.0