コード例 #1
0
void MoveCollectionTask::doRename(KIMAP::Session *session)
{
    // collection.remoteId() already includes the separator
    const QString oldMailBox = mailBoxForCollections(sourceCollection(), collection());
    const QString newMailBox = mailBoxForCollections(targetCollection(), collection());

    if (oldMailBox != newMailBox) {
        KIMAP::RenameJob *job = new KIMAP::RenameJob(session);
        job->setSourceMailBox(oldMailBox);
        job->setDestinationMailBox(newMailBox);

        connect(job, &KIMAP::RenameJob::result, this, &MoveCollectionTask::onRenameDone);

        job->start();

    } else {
        changeProcessed();
    }
}
コード例 #2
0
ファイル: renamejobtest.cpp プロジェクト: pvuorela/kcalcore
void testRename()
{
    QFETCH( QString, mailbox );
    QFETCH( QString, newname );
    QFETCH( QList<QByteArray>, scenario );

    FakeServer fakeServer;
    fakeServer.setScenario( scenario );
    fakeServer.startAndWait();

    KIMAP::Session session( "127.0.0.1", 5989 );

    KIMAP::RenameJob *job = new KIMAP::RenameJob( &session );
    job->setSourceMailBox( mailbox );
    job->setDestinationMailBox( newname );
    bool result = job->exec();
    QEXPECT_FAIL( "bad" , "Expected failure on BAD response", Continue );
    QEXPECT_FAIL( "no" , "Expected failure on NO response", Continue );
    QVERIFY( result );
    QCOMPARE( job->sourceMailBox(), mailbox );
    QCOMPARE( job->destinationMailBox(), newname );

    fakeServer.quit();
}