예제 #1
0
IMAPAsyncConnection * IMAPAsyncSession::sessionForFolder(String * folder, bool urgent)
{
    if (folder == NULL) {
        return matchingSessionForFolder(NULL);
    }
    else {
        IMAPAsyncConnection * s = NULL;

        // try find session with empty queue, selected to the folder
        s = sessionWithMinQueue(true, folder);
        if (s != NULL && s->operationsCount() == 0) {
            s->setLastFolder(folder);
            return s;
        }

        if (urgent && mAllowsFolderConcurrentAccessEnabled) {
            // in urgent mode try reuse any available session with
            // empty queue or create new one, if maximum connections limit does not reached.
            s = availableSession();
            if (s->operationsCount() == 0) {
                s->setLastFolder(folder);
                return s;
            }
        }

        // otherwise returns session with minimum size of queue among selected to the folder.
        s = matchingSessionForFolder(folder);
        s->setLastFolder(folder);
        return s;
    }
}
예제 #2
0
IMAPAsyncConnection * IMAPAsyncSession::sessionForFolder(String * folder, bool urgent)
{
    if (folder == NULL) {
        return availableSession();
    }
    else {
        IMAPAsyncConnection * s = NULL;
        if (urgent && mAllowsFolderConcurrentAccessEnabled) {
            s = availableSession();
            if (s->operationsCount() == 0) {
                s->setLastFolder(folder);
                return s;
            }
        }

        s = matchingSessionForFolder(folder);
        s->setLastFolder(folder);
        return s;
    }
}