File: retrieveitemstask.h

package info (click to toggle)
kdepim-runtime 4%3A24.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,012 kB
  • sloc: cpp: 90,562; xml: 1,020; javascript: 60; sh: 58; makefile: 13
file content (82 lines) | stat: -rw-r--r-- 2,686 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
    SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
    SPDX-FileContributor: Kevin Ottens <kevin@kdab.com>
    SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once

#include <KIMAP/FetchJob>

#include "resourcetask.h"
#include <QElapsedTimer>
class BatchFetcher;
namespace Akonadi
{
class Session;
}

class RetrieveItemsTask : public ResourceTask
{
    Q_OBJECT

public:
    explicit RetrieveItemsTask(const ResourceStateInterface::Ptr &resource, QObject *parent = nullptr);
    ~RetrieveItemsTask() override;
    void setFetchMissingItemBodies(bool enabled);

public Q_SLOTS:
    void onFetchItemsWithoutBodiesDone(const QList<qint64> &items);
    void onReadyForNextBatch(int size);

private Q_SLOTS:
    void fetchItemsWithoutBodiesDone(KJob *job);
    void onPreExpungeSelectDone(KJob *job);
    void onExpungeDone(KJob *job);
    void onFinalSelectDone(KJob *job);
    void onStatusDone(KJob *job);
    void onItemsRetrieved(const Akonadi::Item::List &addedItems);
    void onRetrievalDone(KJob *job);
    void onFlagsFetchDone(KJob *job);

protected:
    void doStart(KIMAP::Session *session) override;

    virtual BatchFetcher *createBatchFetcher(MessageHelper::Ptr messageHelper,
                                             const KIMAP::ImapSet &set,
                                             const KIMAP::FetchJob::FetchScope &scope,
                                             int batchSize,
                                             KIMAP::Session *session);

private:
    void prepareRetrieval();
    void startRetrievalTasks();
    void triggerPreExpungeSelect(const QString &mailBox);
    void triggerExpunge(const QString &mailBox);
    void triggerFinalSelect(const QString &mailBox);
    void retrieveItems(const KIMAP::ImapSet &set, const KIMAP::FetchJob::FetchScope &scope, bool incremental = false, bool uidBased = false);
    void listFlagsForImapSet(const KIMAP::ImapSet &set);
    void taskComplete();

    KIMAP::Session *m_session = nullptr;
    QList<qint64> m_messageUidsMissingBody;
    int m_fetchedMissingBodies = -1;
    bool m_fetchMissingBodies = false;
    bool m_incremental = true;
    qint64 m_localHighestModSeq = -1;
    BatchFetcher *m_batchFetcher = nullptr;
    Akonadi::Collection m_modifiedCollection;
    bool m_uidBasedFetch = true;
    bool m_flagsChanged = false;
    QElapsedTimer m_time;

    // Results of SELECT
    QString m_mailBox;
    int m_messageCount = -1;
    int m_uidValidity = -1;
    qint64 m_nextUid = -1;
    qint64 m_highestModSeq = -1;
    QList<QByteArray> m_flags;
};