Refactoring: move FETCH finalization to a corresponding Task
[trojita.git] / src / Imap / Tasks / FetchMsgPartTask.h
bloba7e4b2c1c0f5e41a3d73580909464c7ab39cf67e
1 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
3 This file is part of the Trojita Qt IMAP e-mail client,
4 http://trojita.flaska.net/
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License or (at your option) version 3 or any later version
10 accepted by the membership of KDE e.V. (or its successor approved
11 by the membership of KDE e.V.), which shall act as a proxy
12 defined in Section 14 of version 3 of the license.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef IMAP_FETCHMSGPARTTASK_H
24 #define IMAP_FETCHMSGPARTTASK_H
26 #include <QPersistentModelIndex>
27 #include "ImapTask.h"
29 namespace Imap {
30 namespace Mailbox {
32 class TreeItemMailbox;
34 /** @short Fetch a message part */
35 class FetchMsgPartTask : public ImapTask
37 Q_OBJECT
38 public:
39 FetchMsgPartTask(Model *model, const QModelIndex &mailbox, const Imap::Uids &uids, const QList<QByteArray> &parts);
40 virtual void perform();
42 virtual bool handleFetch(const Imap::Responses::Fetch *const resp);
43 virtual bool handleStateHelper(const Imap::Responses::State *const resp);
45 virtual QString debugIdentification() const;
46 virtual QVariant taskData(const int role) const;
47 virtual bool needsMailbox() const {return true;}
48 protected slots:
49 void markPendingItemsUnavailable();
50 private:
51 bool finalizeFetchPart(TreeItemMailbox *const mailbox, const uint sequenceNo, const QByteArray &partId);
53 CommandHandle tag;
54 ImapTask *conn;
55 Imap::Uids uids;
56 QList<QByteArray> parts;
57 QPersistentModelIndex mailboxIndex;
63 #endif // IMAP_FETCHMSGPARTTASK_H