bool ThreadTask::handleESearch(const Responses::ESearch *const resp) { if (resp->tag != tag) return false; if (resp->seqOrUids != Imap::Responses::ESearch::UIDS) throw UnexpectedResponseReceived("ESEARCH response to a UID THREAD command with matching tag uses " "sequence numbers instead of UIDs", *resp); if (m_incrementalMode) { emit incrementalThreadingAvailable(resp->incThreadData); return true; } throw UnexpectedResponseReceived("ESEARCH response to UID THREAD received outside of the incremental mode"); }
bool SortTask::handleESearch(const Responses::ESearch *const resp) { if (resp->tag != sortTag) return false; if (resp->seqOrUids != Imap::Responses::ESearch::UIDS) throw UnexpectedResponseReceived("ESEARCH response to a UID SORT command with matching tag uses " "sequence numbers instead of UIDs", *resp); Responses::ESearch::CompareListDataIdentifier<Responses::ESearch::ListData_t> allComparator("ALL"); Responses::ESearch::ListData_t::const_iterator allIterator = std::find_if(resp->listData.constBegin(), resp->listData.constEnd(), allComparator); if (allIterator != resp->listData.constEnd()) { m_firstUntaggedReceived = true; sortResult = allIterator->second; ++allIterator; if (std::find_if(allIterator, resp->listData.constEnd(), allComparator) != resp->listData.constEnd()) throw UnexpectedResponseReceived("ESEARCH contains the ALL key too many times", *resp); if (!resp->incrementalContextData.isEmpty()) throw UnexpectedResponseReceived("ESEARCH contains both ALL result set and some incremental updates", *resp); return true; } Q_ASSERT(allIterator == resp->listData.constEnd()); if (resp->incrementalContextData.isEmpty()) { sortResult.clear(); // This means that there have been no matches // FIXME: cover this in the test suite! return true; } Q_ASSERT(!resp->incrementalContextData.isEmpty()); if (!m_persistentSearch) throw UnexpectedResponseReceived("ESEARCH contains incremental responses even though we haven't requested that", *resp); emit incrementalSortUpdate(resp->incrementalContextData); return true; }