/** @short Helper: synchronization of an empty mailbox A Unlike helperSyncBNoMessages(), this function actually performs the sync with all required responses like UIDVALIDITY and UIDNEXT. It is the caller's responsibility to provide reasonable values for uidNextA and uidValidityA. @see helperSyncBNoMessages() */ void LibMailboxSync::helperSyncANoMessagesCompleteState() { QCOMPARE( model->rowCount( msgListA ), 0 ); model->switchToMailbox( idxA ); cClient(t.mk("SELECT a\r\n")); cServer(QString::fromUtf8("* 0 exists\r\n* OK [uidnext %1] foo\r\n* ok [uidvalidity %2] bar\r\n" ).arg(QString::number(uidNextA), QString::number(uidValidityA)).toUtf8() + t.last("ok completed\r\n")); // Check the cache Imap::Mailbox::SyncState syncState = model->cache()->mailboxSyncState( QLatin1String("a") ); QCOMPARE( syncState.exists(), 0u ); QCOMPARE( syncState.isUsableForSyncing(), true ); QCOMPARE( syncState.uidNext(), uidNextA ); QCOMPARE( syncState.uidValidity(), uidValidityA ); existsA = 0; uidMapA.clear(); helperCheckCache(); helperVerifyUidMapA(); // Verify that we indeed received what we wanted Imap::Mailbox::TreeItemMsgList* list = dynamic_cast<Imap::Mailbox::TreeItemMsgList*>( static_cast<Imap::Mailbox::TreeItem*>( msgListA.internalPointer() ) ); Q_ASSERT( list ); QVERIFY( list->fetched() ); cEmpty(); QVERIFY( errorSpy->isEmpty() ); }
/** @short Helper: make the parser switch to mailbox B which is actually empty This function is useful for making sure that the parser switches to another mailbox and will perform a fresh SELECT when it goes back to the original mailbox. */ void LibMailboxSync::helperSyncBNoMessages() { // Try to go to second mailbox QCOMPARE( model->rowCount( msgListB ), 0 ); model->switchToMailbox( idxB ); cClient(t.mk("SELECT b\r\n")); cServer(QByteArray("* 0 exists\r\n") + t.last("ok completed\r\n")); // Check the cache Imap::Mailbox::SyncState syncState = model->cache()->mailboxSyncState( QLatin1String("b") ); QCOMPARE( syncState.exists(), 0u ); QCOMPARE( syncState.isUsableForSyncing(), false ); QCOMPARE( syncState.uidNext(), 0u ); QCOMPARE( syncState.uidValidity(), 0u ); // Verify that we indeed received what we wanted Q_ASSERT(msgListB.isValid()); Imap::Mailbox::TreeItemMsgList* list = dynamic_cast<Imap::Mailbox::TreeItemMsgList*>( static_cast<Imap::Mailbox::TreeItem*>( msgListB.internalPointer() ) ); Q_ASSERT( list ); QVERIFY( list->fetched() ); cEmpty(); QVERIFY( errorSpy->isEmpty() ); }
QDebug operator<<(QDebug dbg, const Imap::Mailbox::SyncState &state) { dbg << "UIDVALIDITY"; if (state.m_hasUidValidity) dbg << state.uidValidity(); else dbg << "n/a"; dbg << "UIDNEXT"; if (state.m_hasUidNext) dbg << state.uidNext(); else dbg << "n/a"; dbg << "EXISTS"; if (state.m_hasExists) dbg << state.exists(); else dbg << "n/a"; dbg << "HIGHESTMODSEQ"; if (state.m_hasHighestModSeq) dbg << state.highestModSeq(); else dbg << "n/a"; dbg << "UNSEEN-count"; if (state.m_hasUnSeenCount) dbg << state.unSeenCount(); else dbg << "n/a"; dbg << "UNSEEN-offset"; if (state.m_hasUnSeenOffset) dbg << state.unSeenOffset(); else dbg << "n/a"; dbg << "RECENT"; if (state.m_hasRecent) dbg << state.recent(); else dbg << "n/a"; dbg << "PERMANENTFLAGS"; if (state.m_hasPermanentFlags) dbg << state.permanentFlags(); else dbg << "n/a"; return dbg; }