From 2a9b02ff6d2279f7cd301ae1f397d275afa66922 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 28 Nov 2017 14:13:03 +0100 Subject: Fixed imap tests Adjust to cyrus imap settings and use explicit encryption setting. --- examples/imapresource/imapserverproxy.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'examples/imapresource/imapserverproxy.cpp') diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 9a84327..2dd2d46 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -136,13 +136,20 @@ KIMAP2::Session *createNewSession(const QString &serverUrl, int port) return newSession; } -ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr) +ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, EncryptionMode encryptionMode, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr), mEncryptionMode(encryptionMode) { if (!mSessionCache || mSessionCache->isEmpty()) { mSession = createNewSession(serverUrl, port); } } +QDebug operator<<(QDebug debug, const KIMAP2::MailBoxDescriptor &c) +{ + QDebugStateSaver saver(debug); + debug.nospace() << c.name; + return debug; +} + KAsync::Job ImapServerProxy::login(const QString &username, const QString &password) { if (password.isEmpty()) { @@ -164,12 +171,12 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString auto loginJob = new KIMAP2::LoginJob(mSession); loginJob->setUserName(username); loginJob->setPassword(password); - loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain); - if (mSession->port() == 143) { + if (mEncryptionMode == Starttls) { loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true); - } else { + } else if (mEncryptionMode == Tls) { loginJob->setEncryptionMode(QSsl::AnyProtocol, false); } + loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain); auto capabilitiesJob = new KIMAP2::CapabilitiesJob(mSession); QObject::connect(capabilitiesJob, &KIMAP2::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) { -- cgit v1.2.3