| 365 | } |
| 366 | |
| 367 | IMAPAsyncConnection * IMAPAsyncSession::sessionWithMinQueue(bool filterByFolder, String * folder) |
| 368 | { |
| 369 | IMAPAsyncConnection * chosenSession = NULL; |
| 370 | unsigned int minOperationsCount = 0; |
| 371 | |
| 372 | for (unsigned int i = 0 ; i < mSessions->count() ; i ++) { |
| 373 | IMAPAsyncConnection * s = (IMAPAsyncConnection *) mSessions->objectAtIndex(i); |
| 374 | if ((chosenSession == NULL) || (s->operationsCount() < minOperationsCount)) { |
| 375 | bool matched = true; |
| 376 | if (filterByFolder) { |
| 377 | // filter by last selested folder |
| 378 | matched = ((folder != NULL && s->lastFolder() != NULL && s->lastFolder()->isEqual(folder)) |
| 379 | || (folder == NULL && s->lastFolder() == NULL)); |
| 380 | } |
| 381 | if (matched) { |
| 382 | chosenSession = s; |
| 383 | minOperationsCount = s->operationsCount(); |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | return chosenSession; |
| 389 | } |
| 390 | |
| 391 | IMAPFolderInfoOperation * IMAPAsyncSession::folderInfoOperation(String * folder) |
| 392 | { |
nothing calls this directly
no test coverage detected