summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapserverproxy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r--examples/imapresource/imapserverproxy.cpp15
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
139ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr) 139ImapServerProxy::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
146QDebug operator<<(QDebug debug, const KIMAP2::MailBoxDescriptor &c)
147{
148 QDebugStateSaver saver(debug);
149 debug.nospace() << c.name;
150 return debug;
151}
152
146KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) 153KAsync::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) {