IMAP: update cache when manipulating message flags explicitly

Previously, we would not always update the cache when the change was done via
the .SILENT operation. This is now fixed.

Thanks to paalsteek for reporting this.

REVIEW: 114392
IMAP: UNSELECT: only ignore untagged responses

The intention of that code was to only ingore responses which typically arrive
during the opening of the "non-existing" mailbox. The tagged responses which
also happen to be marked with some particular response code shall fall through
to the handler of the respective tag, otherwise we might eat something which is
important.
IMAP: Handle tagged responses even if they contain a response code

The ObtainSynchronizedMailboxTask contained a bug which caused it to skip
processing of the tagged responses when they contained a recognized response
code. This is a real problem when the server sends us something like that in
response to e.g. ESEARCH -- the synchronization process gets effectively stuck
waiting for the UID discovery to finish, which is not going to happen, because
the tagged OK was ignored.

Thanks to Tetja Rediske <tetja@tetja.de> (Kelsar on IRC) for reporting this and
persuading me that this is not a random fluke on his computer, but a bug in
Trojita.

The KeepMailboxOpenTask does not suffer from this bug because its
handleResponseCodeInsideState() already checked for tag being empty prior to
returning true for "already handled, we're done here" case. It makes sense for
Obtain... and Keep...'s code to be designed the same way, so this patch changes
the ObtainSynchronizedMailboxTask::handleResponseCodeInsideState to use the
checks in the same manner as KeepMailboxOpenTask did already. The other tasks
do not seem to suffer from this problem.

The tests were amended to check for both of these.

REVIEW: 114446
Coding style: do not start the identifiers with the underscore
Remove explicit "response kind" tracking which is already done at the class level

The idea is that each class shall correspond to a single response, more or less.
In practice, we use some of the classes for multiple responses which are in fact
very similar. This has led to some duplication where the AbstractResponse::kind
was often shadowed by the same member defined in the child class, which was not
funny to see in backtraces.

This patch removes the AbstractResponse::kind altogether. The member is onstead
only used in those subclasses which actually make use of it.
Make use of C++11's auto
Composer: use @gentoo.org identity when replying to @lists.gentoo.org

In general, if all the other heuristics fail to provide a result, do not require
to match the full domain token, but get along even with those identities which
share only the suffix of the address.

REVIEW: 114532
Complain about unhandled ENABLED, not ENABLE

The name of the response is ENABLED and it helps if the error messages use a
correct name here.
Debugging: report individual items in the ENABLED response separately
GUI: prevent possible division by zero

I'm not sure how I triggered this, but I managed to do so and got SIGFPE as a
result:

 #0  0x000000000046e975 in Gui::ComposeWidget::calculateMaxVisibleRecipients (this=0x40e0090) at /home/jkt/work/prog/trojita/src/Gui/ComposeWidget.cpp:497
 #1  0x0000000000474ae4 in Gui::ComposeWidget::eventFilter (this=0x40e0090, o=<optimized out>, e=<optimized out>) at /home/jkt/work/prog/trojita/src/Gui/ComposeWidget.cpp:890
 #2  0x00007ffff6ccdbf5 in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=<optimized out>, receiver=0x20e6540, event=0x7fffffffbbf0) at kernel/qcoreapplication.cpp:1059
 #3  0x00007ffff7222377 in notify_helper (e=0x7fffffffbbf0, receiver=0x20e6540, this=0x90f1b0) at kernel/qapplication.cpp:4558
 #4  QApplicationPrivate::notify_helper (this=0x90f1b0, receiver=0x20e6540, e=0x7fffffffbbf0) at kernel/qapplication.cpp:4534
 #5  0x00007ffff72277bc in QApplication::notify (this=0x7fffffffd9a0, receiver=0x20e6540, e=0x7fffffffbbf0) at kernel/qapplication.cpp:4423
 #6  0x00007ffff6ccda3c in QCoreApplication::notifyInternal (this=0x7fffffffd9a0, receiver=0x20e6540, event=0x7fffffffbbf0) at kernel/qcoreapplication.cpp:949
 #7  0x00007ffff72cee1e in sendEvent (event=0x7fffffffbbf0, receiver=0x20e6540) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
 #8  QWidgetPrivate::setGeometry_sys (this=0x4a6c110, x=<optimized out>, y=<optimized out>, w=<optimized out>, h=<optimized out>, isMove=true) at kernel/qwidget_x11.cpp:2658
 #9  0x00007ffff727c8fd in QWidget::setGeometry (this=0x20e6540, r=...) at kernel/qwidget.cpp:6974
 #10 0x00007ffff76dd9d4 in QSplitterPrivate::setGeo (this=0x4369080, sls=0x25e9f40, p=0, s=660, allowCollapse=false) at widgets/qsplitter.cpp:750
 #11 0x00007ffff76e09e9 in QSplitterPrivate::doResize (this=0x4369080) at widgets/qsplitter.cpp:549
 #12 0x00007ffff728282e in QWidget::event (this=0x41ecce0, event=0x7fffffffc850) at kernel/qwidget.cpp:8541
 #13 0x00007ffff72223bc in notify_helper (e=0x7fffffffc850, receiver=0x41ecce0, this=0x90f1b0) at kernel/qapplication.cpp:4562
 #14 QApplicationPrivate::notify_helper (this=0x90f1b0, receiver=0x41ecce0, e=0x7fffffffc850) at kernel/qapplication.cpp:4534
 #15 0x00007ffff72277bc in QApplication::notify (this=0x7fffffffd9a0, receiver=0x41ecce0, e=0x7fffffffc850) at kernel/qapplication.cpp:4423
 #16 0x00007ffff6ccda3c in QCoreApplication::notifyInternal (this=0x7fffffffd9a0, receiver=0x41ecce0, event=0x7fffffffc850) at kernel/qcoreapplication.cpp:949
 #17 0x00007ffff72cee1e in sendEvent (event=0x7fffffffc850, receiver=0x41ecce0) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
 #18 QWidgetPrivate::setGeometry_sys (this=0x4369080, x=<optimized out>, y=<optimized out>, w=<optimized out>, h=<optimized out>, isMove=true) at kernel/qwidget_x11.cpp:2658
 #19 0x00007ffff727c8fd in QWidget::setGeometry (this=0x41ecce0, r=...) at kernel/qwidget.cpp:6974
 #20 0x00007ffff76dd9d4 in QSplitterPrivate::setGeo (this=0x47021d0, sls=0x2fb5370, p=0, s=78, allowCollapse=false) at widgets/qsplitter.cpp:750
 #21 0x00007ffff76e09e9 in QSplitterPrivate::doResize (this=0x47021d0) at widgets/qsplitter.cpp:549
 #22 0x00007ffff76e11e0 in QSplitterPrivate::recalc (this=0x47021d0, update=true) at widgets/qsplitter.cpp:463
 #23 0x00007ffff76e13e3 in QSplitter::event (this=0x1efa310, e=0x4097960) at widgets/qsplitter.cpp:1378
 #24 0x00007ffff72223bc in notify_helper (e=0x4097960, receiver=0x1efa310, this=0x90f1b0) at kernel/qapplication.cpp:4562
 #25 QApplicationPrivate::notify_helper (this=0x90f1b0, receiver=0x1efa310, e=0x4097960) at kernel/qapplication.cpp:4534
 #26 0x00007ffff72277bc in QApplication::notify (this=0x7fffffffd9a0, receiver=0x1efa310, e=0x4097960) at kernel/qapplication.cpp:4423
 #27 0x00007ffff6ccda3c in QCoreApplication::notifyInternal (this=0x7fffffffd9a0, receiver=0x1efa310, event=0x4097960) at kernel/qcoreapplication.cpp:949
 #28 0x00007ffff6cd1c3a in sendEvent (event=0x4097960, receiver=0x1efa310) at kernel/qcoreapplication.h:231
 #29 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=<optimized out>, data=0x90ee20) at kernel/qcoreapplication.cpp:1573
 #30 0x00007ffff6d03887 in sendPostedEvents () at kernel/qcoreapplication.h:236
 #31 postEventSourceDispatch (s=<optimized out>) at kernel/qeventdispatcher_glib.cpp:280
 #32 0x00007ffff2b24ad3 in g_main_dispatch (context=0x910450) at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gmain.c:3054
 #33 g_main_context_dispatch (context=0x910450) at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gmain.c:3630
 #34 0x00007ffff2b24e38 in g_main_context_iterate (dispatch=1, block=<optimized out>, context=0x910450, self=<optimized out>) at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gmain.c:3701
 #35 g_main_context_iterate (context=0x910450, block=<optimized out>, dispatch=1, self=<optimized out>) at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gmain.c:3638
 #36 0x00007ffff2b24f2c in g_main_context_iteration (context=0x910450, may_block=1) at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gmain.c:3762
 #37 0x00007ffff6d03d3f in QEventDispatcherGlib::processEvents (this=0x90c7e0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
 #38 0x00007ffff72dd4c6 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
 #39 0x00007ffff6ccbf12 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
 #40 0x00007ffff6ccc287 in QEventLoop::exec (this=0x7fffffffd540, flags=...) at kernel/qeventloop.cpp:204
 #41 0x00007ffff6cd1f95 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1221
 #42 0x000000000043a317 in main (argc=1, argv=<optimized out>) at /home/jkt/work/prog/trojita/src/Gui/main.cpp:86

REVIEW: 114665
IMAP: ignore extra ENABLED CONDSTORE QRESYNC responses when syncing a mailbox

Apparently at least some versions of Kolab are happy to send out unsolicited
ENABLED responses during the SELECT processing despite the fact that the QRESYNC
has been already enabled explicitly. This is in violation of my understanding of
RFC 5161. Reported to Kolab at https://issues.kolab.org/show_bug.cgi?id=2708 .

Thanks to Martin Sandsmark <martin.sandsmark@kde.org> for reporting this and
patiently providing logs until I was sure where the problem is. Much
appreciated!

BUG: 329204
REVIEW: 114666
tests: check marking messages as being replied to

Unfortunately this does not reproduce the issues I'm hitting in that bugreport :(

CCBUG: 329235
Prevent segfault when replying to a message which has disappeared already

The use of a QModelIndex was incorrect; the code was essentially holding a weak
reference to an object which can be deleted in the background. Switching to a
QPersistentModelIndex makes sure that an invalidated index will not be used.

BUG: 329235
CCMAIL: me@jailuthra.in