diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-28 14:13:03 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-28 14:13:03 +0100 |
commit | 2a9b02ff6d2279f7cd301ae1f397d275afa66922 (patch) | |
tree | a5089fb9b7ec31cebc248c9617c664e839dec641 /examples/imapresource/imapserverproxy.cpp | |
parent | 7ec52003ec7f06cbb8897cd70e8d952ead3ca15f (diff) | |
download | sink-2a9b02ff6d2279f7cd301ae1f397d275afa66922.tar.gz sink-2a9b02ff6d2279f7cd301ae1f397d275afa66922.zip |
Fixed imap tests
Adjust to cyrus imap settings and use explicit encryption setting.
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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) | |||
136 | return newSession; | 136 | return newSession; |
137 | } | 137 | } |
138 | 138 | ||
139 | ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr) | 139 | ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, EncryptionMode encryptionMode, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr), mEncryptionMode(encryptionMode) |
140 | { | 140 | { |
141 | if (!mSessionCache || mSessionCache->isEmpty()) { | 141 | if (!mSessionCache || mSessionCache->isEmpty()) { |
142 | mSession = createNewSession(serverUrl, port); | 142 | mSession = createNewSession(serverUrl, port); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | QDebug operator<<(QDebug debug, const KIMAP2::MailBoxDescriptor &c) | ||
147 | { | ||
148 | QDebugStateSaver saver(debug); | ||
149 | debug.nospace() << c.name; | ||
150 | return debug; | ||
151 | } | ||
152 | |||
146 | KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) | 153 | KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) |
147 | { | 154 | { |
148 | if (password.isEmpty()) { | 155 | if (password.isEmpty()) { |
@@ -164,12 +171,12 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString | |||
164 | auto loginJob = new KIMAP2::LoginJob(mSession); | 171 | auto loginJob = new KIMAP2::LoginJob(mSession); |
165 | loginJob->setUserName(username); | 172 | loginJob->setUserName(username); |
166 | loginJob->setPassword(password); | 173 | loginJob->setPassword(password); |
167 | loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain); | 174 | if (mEncryptionMode == Starttls) { |
168 | if (mSession->port() == 143) { | ||
169 | loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true); | 175 | loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true); |
170 | } else { | 176 | } else if (mEncryptionMode == Tls) { |
171 | loginJob->setEncryptionMode(QSsl::AnyProtocol, false); | 177 | loginJob->setEncryptionMode(QSsl::AnyProtocol, false); |
172 | } | 178 | } |
179 | loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain); | ||
173 | 180 | ||
174 | auto capabilitiesJob = new KIMAP2::CapabilitiesJob(mSession); | 181 | auto capabilitiesJob = new KIMAP2::CapabilitiesJob(mSession); |
175 | QObject::connect(capabilitiesJob, &KIMAP2::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) { | 182 | QObject::connect(capabilitiesJob, &KIMAP2::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) { |