1 /* Copyright (C) 2006 - 2013 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/>.
22 #ifndef IMAP_NETWORK_DOWNLOADMANAGER_H
23 #define IMAP_NETWORK_DOWNLOADMANAGER_H
26 #include <QPersistentModelIndex>
27 #include <QNetworkReply>
28 #include "Imap/Model/FullMessageCombiner.h"
29 #include "Imap/Network/MsgPartNetAccessManager.h"
36 /** @short A glue code for managing message parts download
38 This class uses the existing infrastructure provided by the
39 MsgPartNetAccessmanager to faciliate downloading of individual
40 message parts into real files.
42 class FileDownloadManager
: public QObject
46 FileDownloadManager(QObject
*parent
, Imap::Network::MsgPartNetAccessManager
*manager
, const QModelIndex
&partIndex
);
47 static QString
toRealFileName(const QModelIndex
&index
);
48 QVariant
data(int role
) const;
50 void onPartDataTransfered();
51 void onTransferError();
52 void deleteReply(QNetworkReply
*reply
);
55 void downloadMessage();
56 void onMessageDataTransferred();
58 void transferError(const QString
&errorMessage
);
59 void fileNameRequested(QString
*fileName
);
63 Imap::Network::MsgPartNetAccessManager
*manager
;
64 QPersistentModelIndex partIndex
;
68 Imap::Mailbox::FullMessageCombiner
*m_combiner
;
70 FileDownloadManager(const FileDownloadManager
&); // don't implement
71 FileDownloadManager
&operator=(const FileDownloadManager
&); // don't implement
77 #endif // IMAP_NETWORK_DOWNLOADMANAGER_H