AttachmentView: no duplicate signals, disable downloadbuttons on download
[trojita.git] / src / Imap / Network / FileDownloadManager.h
blob091f2d8aa1856825fc5b6d2aba3376a84336cf61
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
25 #include <QFile>
26 #include <QPersistentModelIndex>
27 #include <QNetworkReply>
28 #include "Imap/Model/FullMessageCombiner.h"
29 #include "Imap/Network/MsgPartNetAccessManager.h"
31 namespace Imap
33 namespace Network
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
44 Q_OBJECT
45 public:
46 FileDownloadManager(QObject *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &partIndex);
47 static QString toRealFileName(const QModelIndex &index);
48 QVariant data(int role) const;
49 private slots:
50 void onPartDataTransfered();
51 void onTransferError();
52 void deleteReply(QNetworkReply *reply);
53 public slots:
54 void downloadPart();
55 void downloadMessage();
56 void onMessageDataTransferred();
57 signals:
58 void transferError(const QString &errorMessage);
59 void fileNameRequested(QString *fileName);
60 void started();
61 void succeeded();
62 private:
63 Imap::Network::MsgPartNetAccessManager *manager;
64 QPersistentModelIndex partIndex;
65 QNetworkReply *reply;
66 QFile saving;
67 bool saved;
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