Swap return value and argument of imap_threaded_capability()

imap_threaded_capability() is the only imap_threaded_*() function
which does not return status, instead status is written to a pointer
passed as argument and function returns retrieved capabilities. To
unify behaviour of all imap_threaded_*() functions make it return
status and pass capabilities through an out argument.
Synchronize mailimap deletion against async operations

Right now main thread can free mailimap while its background thread
is still performing operations on it. Fix it by moving deletion to
the worker thread and making sure nobody uses stale pointers.
Use memset to initialize struct etpan_thread_op

also remove duplicated zeroing.
Merge remote-tracking branch 'jakub-kicinski/for-master'
Better fix for bug #3349 (almost all the needed code was there :-)
Fix bug #3354, "Event cancellation uses incorrect method parameter for Content-Type header"