void SubscribeUnsubscribeTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    if (! mailboxIndex.isValid()) {
        // FIXME: add proper fix
        log("Mailbox vanished before we could ask for number of messages inside");
        _completed();
        return;
    }
    TreeItemMailbox *mailbox = dynamic_cast<TreeItemMailbox *>(static_cast<TreeItem *>(mailboxIndex.internalPointer()));
    Q_ASSERT(mailbox);

    switch (operation) {
    case SUBSCRIBE:
        tag = parser->subscribe(mailbox->mailbox());
        break;
    case UNSUBSCRIBE:
        tag = parser->unSubscribe(mailbox->mailbox());
        break;
    default:
        Q_ASSERT(false);
    }
}
Exemplo n.º 2
0
void SortTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    if (! mailboxIndex.isValid()) {
        _failed(tr("Mailbox vanished before we could ask for threading info"));
        return;
    }

    // We can be killed when appropriate
    KeepMailboxOpenTask *keepTask = dynamic_cast<KeepMailboxOpenTask*>(conn);
    Q_ASSERT(keepTask);
    keepTask->feelFreeToAbortCaller(this);

    if (sortCriteria.isEmpty()) {
        if (model->accessParser(parser).capabilitiesFresh &&
                model->accessParser(parser).capabilities.contains(QLatin1String("ESEARCH"))) {
            // We always prefer ESEARCH over SEARCH, if only for its embedded reference to the command tag
            if (model->accessParser(parser).capabilities.contains(QLatin1String("CONTEXT=SEARCH"))) {
                // Hurray, this IMAP server supports incremental ESEARCH updates
                m_persistentSearch = true;
                sortTag = parser->uidESearch("utf-8", searchConditions,
                                             QStringList() << QLatin1String("ALL") << QLatin1String("UPDATE"));
            } else {
                // ESORT without CONTEXT is still worth the effort, if only for the tag reference
                sortTag = parser->uidESearch("utf-8", searchConditions, QStringList() << QLatin1String("ALL"));
            }
        } else {
            // Plain "old" SORT
            sortTag = parser->uidSearch(searchConditions,
                                        // It looks that Exchange 2003 does not support the UTF-8 charset in searches.
                                        // That is, of course, insane, and only illustrates how useless its support of IMAP really is.
                                        model->m_capabilitiesBlacklist.contains(QLatin1String("X-NO-UTF8-SEARCH")) ? QByteArray() : "utf-8"
                                        );
        }
    } else {
        // SEARCH and SORT combined
        if (model->accessParser(parser).capabilitiesFresh &&
                model->accessParser(parser).capabilities.contains(QLatin1String("ESORT"))) {
            // ESORT's better than regular SORT, if only for its embedded reference to the command tag
            if (model->accessParser(parser).capabilities.contains(QLatin1String("CONTEXT=SORT"))) {
                // Hurray, this IMAP server supports incremental SORT updates
                m_persistentSearch = true;
                sortTag = parser->uidESort(sortCriteria, "utf-8", searchConditions,
                                       QStringList() << QLatin1String("ALL") << QLatin1String("UPDATE"));
            } else {
                // ESORT without CONTEXT is still worth the effort, if only for the tag reference
                sortTag = parser->uidESort(sortCriteria, "utf-8", searchConditions, QStringList() << QLatin1String("ALL"));
            }
        } else {
            // Plain "old" SORT
            sortTag = parser->uidSort(sortCriteria, "utf-8", searchConditions);
        }
    }
}
Exemplo n.º 3
0
void NoopTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    tag = parser->noop();
}
Exemplo n.º 4
0
void CreateMailboxTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    tagCreate = parser->create(mailbox);
}
Exemplo n.º 5
0
void GenUrlAuthTask::perform()
{
    parser = conn->parser;
    Q_ASSERT(parser);
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    tag = parser->genUrlAuth(req.toUtf8(), "INTERNAL");
}
Exemplo n.º 6
0
void FetchMsgMetadataTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    Sequence seq = Sequence::fromList(uids);

    // we do not want to use _onlineMessageFetch because it contains UID and FLAGS
    tag = parser->uidFetch(seq, QStringList() << QLatin1String("ENVELOPE") << QLatin1String("INTERNALDATE") <<
                           QLatin1String("BODYSTRUCTURE") << QLatin1String("RFC822.SIZE") <<
                           QLatin1String("BODY.PEEK[HEADER.FIELDS (References List-Post)]"));
}
Exemplo n.º 7
0
void IdTask::perform()
{
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    QMap<QByteArray,QByteArray> identification;
    identification["name"] = "Trojita";
    if (!model->property("trojita-imap-id-no-versions").toBool()) {
        identification["version"] = Common::Application::version.toUtf8();
        identification["os"] = systemPlatformVersion().toUtf8();
    }
    tag = parser->idCommand(identification);
}
Exemplo n.º 8
0
void AppendTask::perform()
{
    parser = conn->parser;
    Q_ASSERT(parser);
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    if (data.isEmpty()) {
        tag = parser->append(targetMailbox, rawMessageData, flags, timestamp);
    } else {
        tag = parser->appendCatenate(targetMailbox, data, flags, timestamp);
    }
}
Exemplo n.º 9
0
void ThreadTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    if (! mailboxIndex.isValid()) {
        _failed("Mailbox vanished before we could ask for threading info");
        return;
    }

    if (m_incrementalMode) {
        tag = parser->uidEThread(algorithm, "utf-8", searchCriteria, QStringList() << "INCTHREAD");
    } else {
        tag = parser->uidThread(algorithm, "utf-8", searchCriteria);
    }
}
void SubscribeUnsubscribeTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    switch (operation) {
    case SUBSCRIBE:
        tag = parser->subscribe(mailboxName);
        break;
    case UNSUBSCRIBE:
        tag = parser->unSubscribe(mailboxName);
        break;
    default:
        Q_ASSERT(false);
    }
}
Exemplo n.º 11
0
void NumberOfMessagesTask::perform()
{
    parser = conn->parser;
    markAsActiveTask();

    IMAP_TASK_CHECK_ABORT_DIE;

    if (! mailboxIndex.isValid()) {
        // FIXME: add proper fix
        log(QLatin1String("Mailbox vanished before we could ask for number of messages inside"));
        _completed();
        return;
    }
    TreeItemMailbox *mailbox = dynamic_cast<TreeItemMailbox *>(static_cast<TreeItem *>(mailboxIndex.internalPointer()));
    Q_ASSERT(mailbox);

    tag = parser->status(mailbox->mailbox(), requestedStatusOptions());
}
Exemplo n.º 12
0
void UnSelectTask::perform()
{
    markAsActiveTask(TASK_PREPEND);

    if (_dead) {
        _failed(tr("Asked to die"));
        return;
    }
    // We really should ignore abort() -- we're a very important task

    if (model->accessParser(parser).maintainingTask) {
        model->accessParser(parser).maintainingTask->breakOrCancelPossibleIdle();
    }
    if (model->accessParser(parser).capabilities.contains(QStringLiteral("UNSELECT"))) {
        unSelectTag = parser->unSelect();
    } else {
        doFakeSelect();
    }
}