69bb3dfa19a0d7d5a657a8d6b0d09b2f03597584
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / qt / qwebdownloaditem_p.h
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
28 class QWebDownloadItemPrivate;
29
30 QT_BEGIN_NAMESPACE
31 class QString;
32 QT_END_NAMESPACE
33
34 namespace WebKit {
35 class QtDownloadManager;
36 class QtWebError;
37 }
38
39 class 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)
47 public:
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
68 public Q_SLOTS:
69     void start();
70     void cancel();
71
72 Q_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
78 private:
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