Ejemplo n.º 1
0
void AkonadiSlave::stat(const QUrl &url)
{
    qCDebug(AKONADISLAVE_LOG) << url;

    // Stats for a collection
    if (Collection::fromUrl(url).isValid()) {
        Collection collection = Collection::fromUrl(url);

        if (collection != Collection::root()) {
            // Check that the collection exists.
            CollectionFetchJob *job = new CollectionFetchJob(collection, CollectionFetchJob::Base);
            if (!job->exec()) {
                error(KIO::ERR_INTERNAL, job->errorString());
                return;
            }

            if (job->collections().count() != 1) {
                error(KIO::ERR_DOES_NOT_EXIST, i18n("No such item."));
                return;
            }

            collection = job->collections().at(0);
        }

        statEntry(entryForCollection(collection));
        finished();
    }
    // Stats for an item
    else if (Item::fromUrl(url).isValid()) {
        ItemFetchJob *job = new ItemFetchJob(Item::fromUrl(url));

        if (!job->exec()) {
            error(KIO::ERR_INTERNAL, job->errorString());
            return;
        }

        if (job->items().count() != 1) {
            error(KIO::ERR_DOES_NOT_EXIST, i18n("No such item."));
            return;
        }

        const Item item = job->items().at(0);
        statEntry(entryForItem(item));
        finished();
    }
}
Ejemplo n.º 2
0
void MailDirRemoveReadMessages::runTest()
{
    timer.start();
    qDebug() << "  Removing read messages from every folder.";
    CollectionFetchJob *clj4 = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive);
    clj4->fetchScope().setResource(currentInstance.identifier());
    clj4->exec();
    const Collection::List list4 = clj4->collections();
    for (const Collection &collection : list4) {
        ItemFetchJob *ifj = new ItemFetchJob(collection, this);
        ifj->exec();
        const auto items = ifj->items();
        for (const Item &item : items) {
            // delete read messages
            if (item.hasFlag("\\SEEN")) {
                ItemDeleteJob *idj = new ItemDeleteJob(item, this);
                idj->exec();
            }
        }
    }
    outputStats(QStringLiteral("removereaditems"));
}
Ejemplo n.º 3
0
void AkonadiSlave::get(const QUrl &url)
{
    const Item item = Item::fromUrl(url);
    ItemFetchJob *job = new ItemFetchJob(item);
    job->fetchScope().fetchFullPayload();

    if (!job->exec()) {
        error(KIO::ERR_INTERNAL, job->errorString());
        return;
    }

    if (job->items().count() != 1) {
        error(KIO::ERR_DOES_NOT_EXIST, i18n("No such item."));
    } else {
        const Item item = job->items().at(0);
        QByteArray tmp = item.payloadData();
        data(tmp);
        data(QByteArray());
        finished();
    }

    finished();
}