Harmattan: remove the server's cached public key when switching servers

I made a mistake in 3f60c878ca33dcd529582985d2135c399cdbca67; the code was not
adapted to also work on the new settings item.
Harmattan: enable persistent cache

There is no settings UI, and therefore no settings to respect. We do not use the
CombinedCache (yet) because there is no support for working with attachments
anyway.
Harmattan: purge cache when switching servers/accounts

Technically, the cache should probably be also purged when changing the
connection setup (plaintext/SSL/TLS), but chances of pointing to a different
account are, hopefully, very small here.
Hamrattan: prevent assert crash when user clicks the "Accept" button twice
SubtreeModel: Prevent assert crash when resetting upon endRemoveRows

This happened because the fallback code within QAbstractProxyModel translated
the index and passed it to the parent's hasChildren, which produced results very
inconsistent with what we were doing here.

Program received signal SIGABRT, Aborted.
0x00007ffff2c14b15 in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
 #0  0x00007ffff2c14b15 in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
 #1  0x00007ffff2c15f8b in __GI_abort () at abort.c:91
 #2  0x00007ffff382d554 in qt_message_output (msgType=<optimized out>, buf=<optimized out>) at global/qglobal.cpp:2323
 #3  0x00007ffff382d713 in qt_message(QtMsgType, const char *, typedef __va_list_tag __va_list_tag *) (msgType=QtFatalMsg, msg=0x7ffff39d0908 "ASSERT: \"%s\" in file %s, line %d", ap=0x7fffffffbe90) at global/qglobal.cpp:2369
 #4  0x00007ffff382d8d9 in qFatal (msg=<optimized out>) at global/qglobal.cpp:2552
 #5  0x00000000005024d4 in KDescendantsProxyModelPrivate::sourceModelReset (this=0x923700) at /home/jkt/work/prog/trojita/src/Imap/Model/kdeui-itemviews/kdescendantsproxymodel.cpp:887
 #6  0x0000000000503654 in KDescendantsProxyModel::qt_static_metacall (_o=0x926e00, _c=QMetaObject::InvokeMetaMethod, _id=7, _a=0x7fffffffc1d0) at /home/jkt/work/prog/_trojita-build/cmake-qt4-clang/moc_kdescendantsproxymodel.cpp:79
 #7  0x00007ffff3971ec1 in QMetaObject::activate (sender=0x9264c0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x0) at kernel/qobject.cpp:3539
 #8  0x00000000004f50be in Imap::Mailbox::SubtreeModel::handleRowsRemoved (this=0x9264c0, parent=..., first=1, last=27) at /home/jkt/work/prog/trojita/src/Imap/Model/SubtreeModel.cpp:276
 #9  0x000000000053c2d8 in Imap::Mailbox::SubtreeModel::qt_static_metacall (_o=0x9264c0, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x7fffffffc4a0) at /home/jkt/work/prog/_trojita-build/cmake-qt4-clang/moc_SubtreeModel.cpp:90
 #10 0x00007ffff3971ec1 in QMetaObject::activate (sender=0x948e00, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fffffffc4a0) at kernel/qobject.cpp:3539
 #11 0x00007ffff39cc164 in QAbstractItemModel::rowsRemoved (this=<optimized out>, _t1=..., _t2=1, _t3=27) at .moc/release-shared/moc_qabstractitemmodel.cpp:211
 #12 0x00007ffff3953cd1 in QAbstractItemModel::endRemoveRows (this=0x948e00) at kernel/qabstractitemmodel.cpp:2487
 #13 0x00000000004c824c in Imap::Mailbox::Model::replaceChildMailboxes (this=0x948e00, mailboxPtr=0x8ebe50, mailboxes=...) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:496
 #14 0x00000000004c7c26 in Imap::Mailbox::Model::finalizeList (this=0x948e00, parser=0x970200, mailboxPtr=0x8ebe50) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:402
 #15 0x000000000051fa7f in Imap::Mailbox::ListChildMailboxesTask::handleStateHelper (this=0x96ee40, resp=0xb3a000) at /home/jkt/work/prog/trojita/src/Imap/Tasks/ListChildMailboxesTask.cpp:96
 #16 0x0000000000513f99 in Imap::Mailbox::ImapTask::handleState (this=0x96ee40, resp=0xb3a000) at /home/jkt/work/prog/trojita/src/Imap/Tasks/ImapTask.cpp:106
 #17 0x000000000057c76d in Imap::Responses::State::plug (this=0xb3a000, task=0x96ee40) at /home/jkt/work/prog/trojita/src/Imap/Parser/Response.cpp:1612
 #18 0x00000000004c521b in Imap::Mailbox::Model::responseReceived (this=0x948e00, it=...) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:232
 #19 0x00000000004c5b1c in Imap::Mailbox::Model::responseReceived (this=0x948e00, parser=0x970200) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:173
 #20 0x00000000005395ad in Imap::Mailbox::Model::qt_static_metacall (_o=0x948e00, _c=QMetaObject::InvokeMetaMethod, _id=38, _a=0xb4fc60) at /home/jkt/work/prog/_trojita-build/cmake-qt4-clang/moc_Model.cpp:187
 #21 0x00007ffff3977716 in QObject::event (this=0x948e00, e=<optimized out>) at kernel/qobject.cpp:1194
 #22 0x00007ffff3eab794 in QApplicationPrivate::notify_helper (this=0x8679d0, receiver=0x948e00, e=0xb2df10) at kernel/qapplication.cpp:4562
 #23 0x00007ffff3eb085d in QApplication::notify (this=0x7fffffffd980, receiver=0x948e00, e=0xb2df10) at kernel/qapplication.cpp:3944
 #24 0x00007ffff395a70c in QCoreApplication::notifyInternal (this=0x7fffffffd980, receiver=0x948e00, event=0xb2df10) at kernel/qcoreapplication.cpp:946
 #25 0x00007ffff395e90a in sendEvent (event=0xb2df10, receiver=0x948e00) at kernel/qcoreapplication.h:231
 #26 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=<optimized out>, data=0x867b60) at kernel/qcoreapplication.cpp:1570
 #27 0x00007ffff39903e7 in sendPostedEvents () at kernel/qcoreapplication.h:236
 #28 postEventSourceDispatch (s=<optimized out>) at kernel/qeventdispatcher_glib.cpp:279
 #29 0x00007fffef2cb603 in g_main_dispatch (context=0x86cf00) at gmain.c:2539
 #30 g_main_context_dispatch (context=0x86cf00) at gmain.c:3075
 #31 0x00007fffef2cb980 in g_main_context_iterate (context=0x86cf00, block=1, dispatch=1, self=<optimized out>) at gmain.c:3146
 #32 0x00007fffef2cba6c in g_main_context_iteration (context=0x86cf00, may_block=1) at gmain.c:3207
 #33 0x00007ffff399089f in QEventDispatcherGlib::processEvents (this=0x868ff0, flags=...) at kernel/qeventdispatcher_glib.cpp:424
 #34 0x00007ffff3f6b156 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
 #35 0x00007ffff3958c92 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
 #36 0x00007ffff3959007 in QEventLoop::exec (this=0x7fffffffd7d0, flags=...) at kernel/qeventloop.cpp:204
 #37 0x00007ffff395ec65 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
 #38 0x000000000049f2e1 in main (argc=1, argv=0x7fffffffda88) at /home/jkt/work/prog/trojita/src/xqmltrojita.cpp:59
Harmattan: fix segfault when removing items

Looks like a case of QTBUG-18592 -- the backtrace is very similar and removing
explicit manipulation of the "current index" prevents this crash.

It was not exactly trivial to reproduce this (on-device debugging always led to
a corrupted stack, or perhaps "just" that-version-of-gdb not being able to work
with whatever-system-setup. In the end, using Scratchbox with the regular amd64
binaries has helped, and this is the backtrace:

Program received signal SIGSEGV, Segmentation fault.
0xf68a298f in QDeclarativeListView::itemsRemoved (this=0x832bd00, modelIndex=0, count=2) at graphicsitems/qdeclarativelistview.cpp:3392
3392    graphicsitems/qdeclarativelistview.cpp: No such file or directory.
        in graphicsitems/qdeclarativelistview.cpp
(gdb) bt
 #0  0xf68a298f in QDeclarativeListView::itemsRemoved (this=0x832bd00, modelIndex=0, count=2) at graphicsitems/qdeclarativelistview.cpp:3392
 #1  0xf69f8cb3 in QDeclarativeListView::qt_metacall (this=0x832bd00, _c=QMetaObject::InvokeMetaMethod, _id=30, _a=0xffffc514)
     at .moc/debug-shared/moc_qdeclarativelistview_p.cpp:485
 #2  0xf5a819ec in QMetaObject::metacall (object=0x832bd00, cl=QMetaObject::InvokeMetaMethod, idx=90, argv=0xffffc514) at kernel/qmetaobject.cpp:237
 #3  0xf5a950cf in QMetaObject::activate (sender=0x853bf30, m=0xf6acddac, local_signal_index=2, argv=0xffffc514) at kernel/qobject.cpp:3280
 #4  0xf69f6ce2 in QDeclarativeVisualModel::itemsRemoved (this=0x853bf30, _t1=0, _t2=2) at .moc/debug-shared/moc_qdeclarativevisualitemmodel_p.cpp:147
 #5  0xf6890631 in QDeclarativeVisualDataModel::_q_itemsRemoved (this=0x853bf30, index=0, count=2) at graphicsitems/qdeclarativevisualitemmodel.cpp:1312
 #6  0xf69f7519 in QDeclarativeVisualDataModel::qt_metacall (this=0x853bf30, _c=QMetaObject::InvokeMetaMethod, _id=8, _a=0xffffc710)
     at .moc/debug-shared/moc_qdeclarativevisualitemmodel_p.cpp:398
 #7  0xf5a819ec in QMetaObject::metacall (object=0x853bf30, cl=QMetaObject::InvokeMetaMethod, idx=20, argv=0xffffc710) at kernel/qmetaobject.cpp:237
 #8  0xf5a950cf in QMetaObject::activate (sender=0x87ceba8, m=0x8227188, local_signal_index=7, argv=0xffffc710) at kernel/qobject.cpp:3280
 #9  0xf5aec638 in QAbstractItemModel::rowsRemoved (this=0x87ceba8, _t1=..., _t2=0, _t3=1) at .moc/debug-shared/moc_qabstractitemmodel.cpp:195
 #10 0xf5a7421d in QAbstractItemModel::endRemoveRows (this=0x87ceba8) at kernel/qabstractitemmodel.cpp:2466
 #11 0x081044af in Imap::Mailbox::SubtreeModel::handleRowsRemoved (this=0x87ceba8, parent=..., first=0, last=1) at /home/harmattan/trojita/src/Imap/Model/SubtreeModel.cpp:282
 #12 0x0813d1bb in Imap::Mailbox::SubtreeModel::qt_metacall (this=0x87ceba8, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0xffffc920)
     at /home/harmattan/trojita/build/moc_SubtreeModel.cpp:113
 #13 0x0813d518 in Imap::Mailbox::SubtreeModelOfMailboxModel::qt_metacall (this=0x87ceba8, _c=QMetaObject::InvokeMetaMethod, _id=30, _a=0xffffc920)
     at /home/harmattan/trojita/build/moc_SubtreeModel.cpp:252
 #14 0xf5a819ec in QMetaObject::metacall (object=0x87ceba8, cl=QMetaObject::InvokeMetaMethod, idx=30, argv=0xffffc920) at kernel/qmetaobject.cpp:237
 #15 0xf5a950cf in QMetaObject::activate (sender=0x88ad108, m=0x8227188, local_signal_index=7, argv=0xffffc920) at kernel/qobject.cpp:3280
 #16 0xf5aec638 in QAbstractItemModel::rowsRemoved (this=0x88ad108, _t1=..., _t2=0, _t3=1) at .moc/debug-shared/moc_qabstractitemmodel.cpp:195
 #17 0xf5a7421d in QAbstractItemModel::endRemoveRows (this=0x88ad108) at kernel/qabstractitemmodel.cpp:2466
 #18 0x080c8725 in Imap::Mailbox::MailboxModel::handleRowsRemoved (this=0x88ad108, parent=..., first=1, last=2) at /home/harmattan/trojita/src/Imap/Model/MailboxModel.cpp:325
 #19 0x0813afa7 in Imap::Mailbox::MailboxModel::qt_metacall (this=0x88ad108, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0xffffcad0)
     at /home/harmattan/trojita/build/moc_MailboxModel.cpp:93
 #20 0xf5a819ec in QMetaObject::metacall (object=0x88ad108, cl=QMetaObject::InvokeMetaMethod, idx=30, argv=0xffffcad0) at kernel/qmetaobject.cpp:237
 #21 0xf5a950cf in QMetaObject::activate (sender=0x87c88c0, m=0x8227188, local_signal_index=7, argv=0xffffcad0) at kernel/qobject.cpp:3280
 #22 0xf5aec638 in QAbstractItemModel::rowsRemoved (this=0x87c88c0, _t1=..., _t2=1, _t3=2) at .moc/debug-shared/moc_qabstractitemmodel.cpp:195
 #23 0xf5a7421d in QAbstractItemModel::endRemoveRows (this=0x87c88c0) at kernel/qabstractitemmodel.cpp:2466
 #24 0x080df418 in Imap::Mailbox::Model::replaceChildMailboxes (this=0x87c88c0, mailboxPtr=0x8c3ac98, mailboxes=...) at /home/harmattan/trojita/src/Imap/Model/Model.cpp:496
 #25 0x080dec3b in Imap::Mailbox::Model::finalizeList (this=0x87c88c0, parser=0x88f1620, mailboxPtr=0x8c3ac98) at /home/harmattan/trojita/src/Imap/Model/Model.cpp:402
 #26 0x08126910 in Imap::Mailbox::ListChildMailboxesTask::handleStateHelper (this=0x8b33f30, resp=0x8cd0580)
     at /home/harmattan/trojita/src/Imap/Tasks/ListChildMailboxesTask.cpp:96
 #27 0x0811d1a2 in Imap::Mailbox::ImapTask::handleState (this=0x8b33f30, resp=0x8cd0580) at /home/harmattan/trojita/src/Imap/Tasks/ImapTask.cpp:106
 #28 0x08179c00 in Imap::Responses::State::plug (this=0x8cd0580, task=0x8b33f30) at /home/harmattan/trojita/src/Imap/Parser/Response.cpp:1612
 #29 0x080dda70 in Imap::Mailbox::Model::responseReceived (this=0x87c88c0, it=...) at /home/harmattan/trojita/src/Imap/Model/Model.cpp:232
 #30 0x080dd663 in Imap::Mailbox::Model::responseReceived (this=0x87c88c0, parser=0x88f1620) at /home/harmattan/trojita/src/Imap/Model/Model.cpp:173
 #31 0x0813b659 in Imap::Mailbox::Model::qt_metacall (this=0x87c88c0, _c=QMetaObject::InvokeMetaMethod, _id=38, _a=0x8bee9b0) at /home/harmattan/trojita/build/moc_Model.cpp:210
 #32 0xf5a819ec in QMetaObject::metacall (object=0x87c88c0, cl=QMetaObject::InvokeMetaMethod, idx=62, argv=0x8bee9b0) at kernel/qmetaobject.cpp:237
 #33 0xf5a8cdf9 in QMetaCallEvent::placeMetaCall (this=0x8789c88, object=0x87c88c0) at kernel/qobject.cpp:537
 #34 0xf5a8d400 in QObject::event (this=0x87c88c0, e=0x1) at kernel/qobject.cpp:1219
 #35 0xf5cecd49 in QApplicationPrivate::notify_helper (this=0x822d290, receiver=0x87c88c0, e=0x8789c88) at kernel/qapplication.cpp:4478
 #36 0xf5cf8a93 in QApplication::notify (this=0xffffd590, receiver=0x87c88c0, e=0x8789c88) at kernel/qapplication.cpp:4357
 #37 0xf5a797c8 in QCoreApplication::notifyInternal (this=0xffffd590, receiver=0x87c88c0, event=0x8789c88) at kernel/qcoreapplication.cpp:787
 #38 0xf5a7bfa4 in sendEvent (receiver=0x0, event_type=0, data=0x822d588) at kernel/qcoreapplication.h:215
 #39 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x822d588) at kernel/qcoreapplication.cpp:1428
 #40 0xf5a7c267 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1321
 #41 0xf5aac0e6 in sendPostedEvents (s=0x822fb18) at kernel/qcoreapplication.h:220
 #42 postEventSourceDispatch (s=0x822fb18) at kernel/qeventdispatcher_glib.cpp:277
 #43 0xf45a792b in g_main_context_dispatch () from /lib/libglib-2.0.so.0
 #44 0xf45abfb9 in ?? () from /lib/libglib-2.0.so.0
 #45 0xf45ac139 in g_main_context_iteration () from /lib/libglib-2.0.so.0
 #46 0xf5aabc4e in QEventDispatcherGlib::processEvents (this=0x822d888, flags=...) at kernel/qeventdispatcher_glib.cpp:422
 #47 0xf5db392b in QGuiEventDispatcherGlib::processEvents (this=0x822d888, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
 #48 0xf5a782f1 in QEventLoop::processEvents (this=0xffffd4e4, flags=...) at kernel/qeventloop.cpp:149
 #49 0xf5a78768 in QEventLoop::exec (this=0xffffd4e4, flags=...) at kernel/qeventloop.cpp:201
 #50 0xf5a7c311 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1064
 #51 0xf5ceb979 in QApplication::exec () at kernel/qapplication.cpp:3752
 #52 0x080bcd33 in main (argc=1, argv=0xffffd684) at /home/harmattan/trojita/src/Harmattan/main.cpp:47
Merge branch 'harmattan-permanent-cache'

REVIEW: 112550
Streams: do not depend on the libImap's exceptions

There is no reason for libStreams to throw exceptions which logically belong to
the IMAP implementation. These are never caught anywhere, so this is a safe
change. Thanks to Pali for spotting this when improving the cmake buildsystem.
coding style
Streams: move to a dedicated namespace

There is no reason to have the classes related to Streams and network IO located
in the Imap namespace.  The SocketFactoryPtr is an exception; it's a
Model-specific implementation detail (nothing requires this particular ownership
semantic under different circumstances).
Update debian files

Reason for this patch is ability to create native package DEB on Debian/Ubuntu
systems with native tools for creating DEB packages (dpkg-buildpackage or
debuild wrapper).

Because we do not support old Ubuntu and Debian systems, debian package can be
updated to use debhelper version 8, which simplify debian/rules file.
Ubuntu precise has debhelper 9 and Debian squeeze has debhelper 8.

It is needed to test if this change does not break OBS.

REVIEW: 112600
CMake: Fix missing libraries when linking and simplify code for compiling main trojita executable

REVIEW: 112572
Merge remote-tracking branch 'pali/pali-cmake'

REVIEW: 112642
MessageView: don't show spinner when network is not available

Since the network is not available, the message won't ever finish
loading and the spinner will stay there forever. Now, just don't show
the spinner.

REVIEW: 112656