diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-08 14:35:05 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-08 14:35:05 +0100 |
commit | 92baf12b456074725cfb74cba601dafd881c3a0a (patch) | |
tree | 37da4630db6e327e991b7a1cf907556e9f64c45b | |
parent | 792e3a05c4506302d1ff00ef7b012440f3510c17 (diff) | |
download | sink-92baf12b456074725cfb74cba601dafd881c3a0a.tar.gz sink-92baf12b456074725cfb74cba601dafd881c3a0a.zip |
Remove disconnected sessions from the cached pool.
-rw-r--r-- | examples/imapresource/imapserverproxy.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h index 84343eb..a8d5ac1 100644 --- a/examples/imapresource/imapserverproxy.h +++ b/examples/imapresource/imapserverproxy.h | |||
@@ -171,6 +171,11 @@ public: | |||
171 | { | 171 | { |
172 | } | 172 | } |
173 | 173 | ||
174 | bool operator==(const CachedSession &other) const | ||
175 | { | ||
176 | return mSession && (mSession == other.mSession); | ||
177 | } | ||
178 | |||
174 | bool isConnected() | 179 | bool isConnected() |
175 | { | 180 | { |
176 | return (mSession->state() == KIMAP2::Session::State::Authenticated || mSession->state() == KIMAP2::Session::State::Selected) ; | 181 | return (mSession->state() == KIMAP2::Session::State::Authenticated || mSession->state() == KIMAP2::Session::State::Selected) ; |
@@ -191,6 +196,11 @@ class SessionCache : public QObject { | |||
191 | public: | 196 | public: |
192 | void recycleSession(const CachedSession &session) | 197 | void recycleSession(const CachedSession &session) |
193 | { | 198 | { |
199 | QObject::connect(session.mSession, &KIMAP2::Session::stateChanged, this, [this, session](KIMAP2::Session::State newState, KIMAP2::Session::State oldState) { | ||
200 | if (newState == KIMAP2::Session::Disconnected) { | ||
201 | mSessions.removeOne(session); | ||
202 | } | ||
203 | }); | ||
194 | mSessions << session; | 204 | mSessions << session; |
195 | } | 205 | } |
196 | 206 | ||