Adding missing Q_DECLARE_METATYPE

Turns out that the tests are producing a warning which is unfortunately ignored
by our ctest invocation :(
Replace QMetaObject::invokeMethod with a wrapper which checks the result
Be much more resilient towards re-entering the event loop

Previously, there used to be a rather primitive guard which attempted to keep
stuff from hitting the fan when the event loop was reentered from within a slot
connected to some signal which was emitted by the IMAP event handlers; the
motivation heind this was that some of the followup events might very well break
stuff by e.g. deciding to kill the parser, or perhaps by deleting some tasks.
Unfortunately, the guard was rather primitive and only ever guarded against
reentering the loop once. It was utterly useless when the loop was reentered
multiple times.

One way of triggering the issue was via connecting to a server which refused our
conneciton due to too many attempts (with a cached password). The three
overlapping dialogs proved to be too much for the primitive guard to handle.
Thanks to paalsteek for reporting this.

This change instead makes sure that the signals which are "likely" to have
something connected to them, and where that "something" might be willing to
re-enter the event loop by e.g. using of QMessageBox' static methods, are only
emitted after a while via the Qt::QueuedConnection.

v2: use EMIT_LATER instead of CALL_LATER for cases where it's about emitting
signals as suggested by Thomas during review.

REVIEW: 114337