summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/imapresource/imapserverproxy.cpp22
-rw-r--r--examples/imapresource/imapserverproxy.h7
2 files changed, 21 insertions, 8 deletions
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index d3ad2d4..7fa0b5a 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -99,17 +99,25 @@ static KAsync::Job<void> runJob(KJob *job)
99 }); 99 });
100} 100}
101 101
102ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache) : mSession(new KIMAP2::Session(serverUrl, qint16(port))), mSessionCache(sessionCache) 102KIMAP2::Session *createNewSession(const QString &serverUrl, int port)
103{ 103{
104 QObject::connect(mSession, &KIMAP2::Session::sslErrors, [this](const QList<QSslError> &errors) { 104 auto newSession = new KIMAP2::Session(serverUrl, qint16(port));
105 if (Sink::Test::testModeEnabled()) {
106 newSession->setTimeout(1);
107 } else {
108 newSession->setTimeout(40);
109 }
110 QObject::connect(newSession, &KIMAP2::Session::sslErrors, [=](const QList<QSslError> &errors) {
105 SinkLog() << "Received ssl error: " << errors; 111 SinkLog() << "Received ssl error: " << errors;
106 mSession->ignoreErrors(errors); 112 newSession->ignoreErrors(errors);
107 }); 113 });
114 return newSession;
115}
108 116
109 if (Sink::Test::testModeEnabled()) { 117ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr)
110 mSession->setTimeout(1); 118{
111 } else { 119 if (!mSessionCache || mSessionCache->isEmpty()) {
112 mSession->setTimeout(40); 120 mSession = createNewSession(serverUrl, port);
113 } 121 }
114} 122}
115 123
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 2d90f39..82f4f58 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -231,7 +231,12 @@ public:
231 return session; 231 return session;
232 } 232 }
233 } 233 }
234 return CachedSession{}; 234 return {};
235 }
236
237 bool isEmpty() const
238 {
239 return mSessions.isEmpty();
235 } 240 }
236private: 241private:
237 QList<CachedSession> mSessions; 242 QList<CachedSession> mSessions;