void MoveCollectionTask::onRenameDone(KJob *job) { if (job->error()) { cancelTask(job->errorString()); } else { // Automatically subscribe to the new mailbox name KIMAP::RenameJob *rename = static_cast<KIMAP::RenameJob *>(job); KIMAP::SubscribeJob *subscribe = new KIMAP::SubscribeJob(rename->session()); subscribe->setMailBox(rename->destinationMailBox()); connect(subscribe, &KIMAP::SubscribeJob::result, this, &MoveCollectionTask::onSubscribeDone); subscribe->start(); } }
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(); } }
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(); }