imap: WIP of getting fetching headers to work.

* Changed the FetchListener mechanism quite a bit.
* Doesn't seem to work correctly yet, although most pieces are in
  place now.