MCPcopy Create free account
hub / github.com/MailCore/mailcore2 / sessionForFolder

Method sessionForFolder

src/async/imap/MCIMAPAsyncSession.cpp:287–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287IMAPAsyncConnection * IMAPAsyncSession::sessionForFolder(String * folder, bool urgent)
288{
289 if (folder == NULL) {
290 return matchingSessionForFolder(NULL);
291 }
292 else {
293 IMAPAsyncConnection * s = NULL;
294
295 // try find session with empty queue, selected to the folder
296 s = sessionWithMinQueue(true, folder);
297 if (s != NULL && s->operationsCount() == 0) {
298 s->setLastFolder(folder);
299 return s;
300 }
301
302 if (urgent && mAllowsFolderConcurrentAccessEnabled) {
303 // in urgent mode try reuse any available session with
304 // empty queue or create new one, if maximum connections limit does not reached.
305 s = availableSession();
306 if (s->operationsCount() == 0) {
307 s->setLastFolder(folder);
308 return s;
309 }
310 }
311
312 // otherwise returns session with minimum size of queue among selected to the folder.
313 s = matchingSessionForFolder(folder);
314 s->setLastFolder(folder);
315 return s;
316 }
317}
318
319IMAPAsyncConnection * IMAPAsyncSession::availableSession()
320{

Callers 1

startMethod · 0.80

Calls 2

operationsCountMethod · 0.80
setLastFolderMethod · 0.80

Tested by

no test coverage detected