1/*
2 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef qwebdownloaditem_p_h
22#define qwebdownloaditem_p_h
23
24#include "qwebkitglobal.h"
25#include <QObject>
26#include <QUrl>
27
28class QWebDownloadItemPrivate;
29
30QT_BEGIN_NAMESPACE
31class QString;
32QT_END_NAMESPACE
33
34namespace WebKit {
35class QtDownloadManager;
36class QtWebError;
37}
38
39class QWEBKIT_EXPORT QWebDownloadItem : public QObject {
40    Q_OBJECT
41    Q_PROPERTY(quint64 expectedContentLength READ expectedContentLength CONSTANT FINAL)
42    Q_PROPERTY(QString destinationPath READ destinationPath WRITE setDestinationPath)
43    Q_PROPERTY(QString suggestedFilename READ suggestedFilename CONSTANT FINAL)
44    Q_PROPERTY(quint64 totalBytesReceived READ totalBytesReceived NOTIFY totalBytesReceivedChanged FINAL)
45    Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
46    Q_ENUMS(DownloadError)
47public:
48    virtual ~QWebDownloadItem();
49
50    enum DownloadError {
51        Aborted = 0,
52        CannotWriteToFile,
53        CannotOpenFile,
54        DestinationAlreadyExists,
55        Cancelled,
56        CannotDetermineFilename,
57        NetworkFailure
58    };
59
60    QUrl url() const;
61    QString destinationPath() const;
62    QString suggestedFilename() const;
63    QString mimeType() const;
64    quint64 expectedContentLength() const;
65    quint64 totalBytesReceived() const;
66    void setDestinationPath(const QString& destination);
67
68public Q_SLOTS:
69    void start();
70    void cancel();
71
72Q_SIGNALS:
73    void destinationFileCreated(const QString& destinationPath);
74    void totalBytesReceivedChanged(quint64 bytesReceived);
75    void succeeded();
76    void failed(QWebDownloadItem::DownloadError error, const QUrl& url, const QString& description);
77
78private:
79    QWebDownloadItem(QObject* parent = 0);
80    QWebDownloadItemPrivate* d;
81
82    friend class WebKit::QtDownloadManager;
83    friend class QQuickWebViewPrivate;
84};
85
86#endif // qwebdownloaditem_p_h
87