diff options
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index ce379de..918a21a 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp | |||
@@ -129,14 +129,18 @@ static KAsync::Job<void> runJob(KJob *job) | |||
129 | }); | 129 | }); |
130 | } | 130 | } |
131 | 131 | ||
132 | KIMAP2::Session *createNewSession(const QString &serverUrl, int port) | 132 | static int socketTimeout() |
133 | { | 133 | { |
134 | auto newSession = new KIMAP2::Session(serverUrl, qint16(port)); | ||
135 | if (Sink::Test::testModeEnabled()) { | 134 | if (Sink::Test::testModeEnabled()) { |
136 | newSession->setTimeout(1); | 135 | return 1; |
137 | } else { | ||
138 | newSession->setTimeout(40); | ||
139 | } | 136 | } |
137 | return 40; | ||
138 | } | ||
139 | |||
140 | KIMAP2::Session *createNewSession(const QString &serverUrl, int port) | ||
141 | { | ||
142 | auto newSession = new KIMAP2::Session(serverUrl, qint16(port)); | ||
143 | newSession->setTimeout(socketTimeout()); | ||
140 | QObject::connect(newSession, &KIMAP2::Session::sslErrors, [=](const QList<QSslError> &errors) { | 144 | QObject::connect(newSession, &KIMAP2::Session::sslErrors, [=](const QList<QSslError> &errors) { |
141 | SinkLog() << "Received ssl error: " << errors; | 145 | SinkLog() << "Received ssl error: " << errors; |
142 | newSession->ignoreErrors(errors); | 146 | newSession->ignoreErrors(errors); |
@@ -173,6 +177,8 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString | |||
173 | } | 177 | } |
174 | Q_ASSERT(mSession); | 178 | Q_ASSERT(mSession); |
175 | if (mSession->state() == KIMAP2::Session::Authenticated || mSession->state() == KIMAP2::Session::Selected) { | 179 | if (mSession->state() == KIMAP2::Session::Authenticated || mSession->state() == KIMAP2::Session::Selected) { |
180 | //Prevent the socket from timing out right away, right here (otherwise it just might time out right before we were able to start the job) | ||
181 | mSession->setTimeout(socketTimeout()); | ||
176 | SinkLog() << "Reusing existing session."; | 182 | SinkLog() << "Reusing existing session."; |
177 | return KAsync::null(); | 183 | return KAsync::null(); |
178 | } | 184 | } |