示例#1
0
IMAPAsyncConnection * IMAPAsyncSession::matchingSessionForFolder(String * folder)
{
    for(unsigned int i = 0 ; i < mSessions->count() ; i ++) {
        IMAPAsyncConnection * currentSession = (IMAPAsyncConnection *) mSessions->objectAtIndex(i);
        if (currentSession->lastFolder() != NULL) {
            if (currentSession->lastFolder()->isEqual(folder)) {
                return currentSession;
            }
        }
        else {
            return currentSession;
        }
    }
    return availableSession();
}
示例#2
0
IMAPAsyncConnection * IMAPAsyncSession::sessionWithMinQueue(bool filterByFolder, String * folder)
{
    IMAPAsyncConnection * chosenSession = NULL;
    unsigned int minOperationsCount = 0;

    for (unsigned int i = 0 ; i < mSessions->count() ; i ++) {
        IMAPAsyncConnection * s = (IMAPAsyncConnection *) mSessions->objectAtIndex(i);
        if ((chosenSession == NULL) || (s->operationsCount() < minOperationsCount)) {
            bool matched = true;
            if (filterByFolder) {
                // filter by last selested folder
                matched = ((folder != NULL && s->lastFolder() != NULL && s->lastFolder()->isEqual(folder))
                           || (folder == NULL && s->lastFolder() == NULL));
            }
            if (matched) {
                chosenSession = s;
                minOperationsCount = s->operationsCount();
            }
        }
    }

    return chosenSession;
}