summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorViktor Engelmann <viktor.engelmann@qt.io>2016-11-14 16:35:09 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-12-07 09:48:24 +0000
commit6644981dfde2ad24186156d5c31a74c686b5557a (patch)
tree3b732a9a2749a9b4469bea9d98dbc4746a099ebc /src
parent3d000cfc013158f56c0b088c9ee99b03938ef50b (diff)
Add DownloadInterruptReason to Q(Quick)WebEngineDownloadItem
Add enum DownloadInterruptReason to BrowserContextAdapterClient, QWebEngineDownloadItem and QQuickWebEngineDownloadItem. Also add corresponding attributes to BrowserContextAdapterClient::DownloadItemInfo, QWebEngineDownloadItemPrivate and QQuickWebEngineDownloadItemPrivate as well as getters in QWebEngineDownloadItem and QQuickWebEngineDownloadItem and interruptReasonChanged signals. Task-number: QTBUG-56839 Change-Id: I937c14ba0b0884b14ae18ba297024b76dde62605 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/browser_context_adapter_client.h31
-rw-r--r--src/core/download_manager_delegate_qt.cpp37
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp85
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h34
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h1
-rw-r--r--src/webengine/plugin/plugin.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp98
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h33
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h1
9 files changed, 319 insertions, 3 deletions
diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h
index faba08591..1eabbe7a0 100644
--- a/src/core/browser_context_adapter_client.h
+++ b/src/core/browser_context_adapter_client.h
@@ -76,6 +76,36 @@ public:
SavePage
};
+ enum DownloadInterruptReason {
+ NoReason = 0,
+ FileFailed = 1,
+ FileAccessDenied = 2,
+ FileNoSpace = 3,
+ FileNameTooLong = 5,
+ FileTooLarge = 6,
+ FileVirusInfected = 7,
+ FileTransientError = 10,
+ FileBlocked = 11,
+ FileSecurityCheckFailed = 12,
+ FileTooShort = 13,
+ FileHashMismatch = 14,
+ NetworkFailed = 20,
+ NetworkTimeout = 21,
+ NetworkDisconnected = 22,
+ NetworkServerDown = 23,
+ NetworkInvalidRequest = 24,
+ ServerFailed = 30,
+ //ServerNoRange = 31,
+ ServerBadContent = 33,
+ ServerUnauthorized = 34,
+ ServerCertProblem = 35,
+ ServerForbidden = 36,
+ ServerUnreachable = 37,
+ UserCanceled = 40,
+ //UserShutdown = 41,
+ //Crash = 50
+ };
+
struct DownloadItemInfo {
const quint32 id;
const QUrl url;
@@ -88,6 +118,7 @@ public:
int savePageFormat;
bool accepted;
int downloadType;
+ int downloadInterruptReason;
};
virtual ~BrowserContextAdapterClient() { }
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 2cbfd121b..5018d94aa 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -71,6 +71,34 @@ ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_AS_ONLY_HTML, BrowserContextAdapterCl
ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, BrowserContextAdapterClient::CompleteHtmlSaveFormat)
ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_AS_MHTML, BrowserContextAdapterClient::MimeHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NONE, BrowserContextAdapterClient::NoReason)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, BrowserContextAdapterClient::FileFailed)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, BrowserContextAdapterClient::FileAccessDenied)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, BrowserContextAdapterClient::FileNoSpace)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, BrowserContextAdapterClient::FileNameTooLong)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE, BrowserContextAdapterClient::FileTooLarge)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_VIRUS_INFECTED, BrowserContextAdapterClient::FileVirusInfected)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, BrowserContextAdapterClient::FileTransientError)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED, BrowserContextAdapterClient::FileBlocked)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED, BrowserContextAdapterClient::FileSecurityCheckFailed)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT, BrowserContextAdapterClient::FileTooShort)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH, BrowserContextAdapterClient::FileHashMismatch)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, BrowserContextAdapterClient::NetworkFailed)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, BrowserContextAdapterClient::NetworkTimeout)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, BrowserContextAdapterClient::NetworkDisconnected)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN, BrowserContextAdapterClient::NetworkServerDown)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST, BrowserContextAdapterClient::NetworkInvalidRequest)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, BrowserContextAdapterClient::ServerFailed)
+//ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE, BrowserContextAdapterClient::ServerNoRange)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, BrowserContextAdapterClient::ServerBadContent)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, BrowserContextAdapterClient::ServerUnauthorized)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM, BrowserContextAdapterClient::ServerCertProblem)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN, BrowserContextAdapterClient::ServerForbidden)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE, BrowserContextAdapterClient::ServerUnreachable)
+ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, BrowserContextAdapterClient::UserCanceled)
+//ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, BrowserContextAdapterClient::UserShutdown)
+//ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_CRASH, BrowserContextAdapterClient::Crash)
+
DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *contextAdapter)
: m_contextAdapter(contextAdapter)
, m_currentId(0)
@@ -165,7 +193,8 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
suggestedFilePath,
BrowserContextAdapterClient::UnknownSavePageFormat,
false /* accepted */,
- m_downloadType
+ m_downloadType,
+ item->GetLastReason()
};
Q_FOREACH (BrowserContextAdapterClient *client, clients) {
@@ -254,7 +283,8 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
suggestedFilePath,
suggestedSaveFormat,
acceptedByDefault,
- BrowserContextAdapterClient::SavePage
+ BrowserContextAdapterClient::SavePage,
+ BrowserContextAdapterClient::NoReason
};
Q_FOREACH (BrowserContextAdapterClient *client, clients) {
@@ -291,7 +321,8 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa
QString(),
BrowserContextAdapterClient::UnknownSavePageFormat,
true /* accepted */,
- m_downloadType
+ m_downloadType,
+ download->GetLastReason()
};
Q_FOREACH (BrowserContextAdapterClient *client, clients) {
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index 8bf319b85..8a6bd0407 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -45,6 +45,34 @@ using QtWebEngineCore::BrowserContextAdapterClient;
QT_BEGIN_NAMESPACE
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NoReason, QQuickWebEngineDownloadItem::NoReason)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileFailed, QQuickWebEngineDownloadItem::FileFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileAccessDenied, QQuickWebEngineDownloadItem::FileAccessDenied)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNoSpace, QQuickWebEngineDownloadItem::FileNoSpace)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNameTooLong, QQuickWebEngineDownloadItem::FileNameTooLong)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooLarge, QQuickWebEngineDownloadItem::FileTooLarge)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileVirusInfected, QQuickWebEngineDownloadItem::FileVirusInfected)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTransientError, QQuickWebEngineDownloadItem::FileTransientError)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileBlocked, QQuickWebEngineDownloadItem::FileBlocked)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileSecurityCheckFailed, QQuickWebEngineDownloadItem::FileSecurityCheckFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooShort, QQuickWebEngineDownloadItem::FileTooShort)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileHashMismatch, QQuickWebEngineDownloadItem::FileHashMismatch)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkFailed, QQuickWebEngineDownloadItem::NetworkFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkTimeout, QQuickWebEngineDownloadItem::NetworkTimeout)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkDisconnected, QQuickWebEngineDownloadItem::NetworkDisconnected)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkServerDown, QQuickWebEngineDownloadItem::NetworkServerDown)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkInvalidRequest, QQuickWebEngineDownloadItem::NetworkInvalidRequest)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerFailed, QQuickWebEngineDownloadItem::ServerFailed)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerNoRange, QQuickWebEngineDownloadItem::ServerNoRange)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerBadContent, QQuickWebEngineDownloadItem::ServerBadContent)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnauthorized, QQuickWebEngineDownloadItem::ServerUnauthorized)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerCertProblem, QQuickWebEngineDownloadItem::ServerCertProblem)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerForbidden, QQuickWebEngineDownloadItem::ServerForbidden)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnreachable, QQuickWebEngineDownloadItem::ServerUnreachable)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserCanceled, QQuickWebEngineDownloadItem::UserCanceled)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserShutdown, QQuickWebEngineDownloadItem::UserShutdown)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::Crash, QQuickWebEngineDownloadItem::Crash)
+
static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int state) {
switch (state) {
case BrowserContextAdapterClient::DownloadInProgress:
@@ -61,12 +89,18 @@ static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int sta
}
}
+static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
+{
+ return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason);
+}
+
QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p)
: profile(p)
, downloadId(-1)
, downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
, savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat)
, type(QQuickWebEngineDownloadItem::Attachment)
+ , interruptReason(QQuickWebEngineDownloadItem::NoReason)
, totalBytes(-1)
, receivedBytes(0)
{
@@ -97,6 +131,11 @@ void QQuickWebEngineDownloadItemPrivate::update(const BrowserContextAdapterClien
updateState(toDownloadState(info.state));
+ if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
+ interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
+ Q_EMIT q->interruptReasonChanged();
+ }
+
if (info.receivedBytes != receivedBytes) {
receivedBytes = info.receivedBytes;
Q_EMIT q->receivedBytesChanged();
@@ -326,6 +365,52 @@ QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() co
return d->type;
}
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::interruptReason
+ \readonly
+ \since QtWebEngine 1.6
+
+ Returns the reason why the download was interrupted:
+
+ \value WebEngineDownloadItem.NoReason Unknown reason or not interrupted.
+ \value WebEngineDownloadItem.FileFailed General file operation failure.
+ \value WebEngineDownloadItem.FileAccessDenied The file cannot be written locally, due to access restrictions.
+ \value WebEngineDownloadItem.FileNoSpace Insufficient space on the target drive.
+ \value WebEngineDownloadItem.FileNameTooLong The directory or file name is too long.
+ \value WebEngineDownloadItem.FileTooLarge The file size exceeds the file system limitation.
+ \value WebEngineDownloadItem.FileVirusInfected The file is infected with a virus.
+ \value WebEngineDownloadItem.FileTransientError Temporary problem (for example the file is in use,
+ out of memory, or too many files are opened at once).
+ \value WebEngineDownloadItem.FileBlocked The file was blocked due to local policy.
+ \value WebEngineDownloadItem.FileSecurityCheckFailed An attempt to check the safety of the download
+ failed due to unexpected reasons.
+ \value WebEngineDownloadItem.FileTooShort An attempt was made to seek past the end of a file when
+ opening a file (as part of resuming a previously interrupted download).
+ \value WebEngineDownloadItem.FileHashMismatch The partial file did not match the expected hash.
+
+ \value WebEngineDownloadItem.NetworkFailed General network failure.
+ \value WebEngineDownloadItem.NetworkTimeout The network operation has timed out.
+ \value WebEngineDownloadItem.NetworkDisconnected The network connection has been terminated.
+ \value WebEngineDownloadItem.NetworkServerDown The server has gone down.
+ \value WebEngineDownloadItem.NetworkInvalidRequest The network request was invalid (for example, the
+ original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
+
+ \value WebEngineDownloadItem.ServerFailed General server failure.
+ \value WebEngineDownloadItem.ServerBadContent The server does not have the requested data.
+ \value WebEngineDownloadItem.ServerUnauthorized The server did not authorize access to the resource.
+ \value WebEngineDownloadItem.ServerCertProblem A problem with the server certificate occurred.
+ \value WebEngineDownloadItem.ServerForbidden Access forbidden by the server.
+ \value WebEngineDownloadItem.ServerUnreachable Unexpected server response (might indicate that
+ the responding server may not be the intended server).
+ \value WebEngineDownloadItem.UserCanceled The user canceled the download.
+*/
+
+QQuickWebEngineDownloadItem::DownloadInterruptReason QQuickWebEngineDownloadItem::interruptReason() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->interruptReason;
+}
+
QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index 61e019b9e..ee7ade6e7 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -82,6 +82,37 @@ public:
};
Q_ENUM(SavePageFormat)
+ enum DownloadInterruptReason {
+ NoReason = 0,
+ FileFailed = 1,
+ FileAccessDenied = 2,
+ FileNoSpace = 3,
+ FileNameTooLong = 5,
+ FileTooLarge = 6,
+ FileVirusInfected = 7,
+ FileTransientError = 10,
+ FileBlocked = 11,
+ FileSecurityCheckFailed = 12,
+ FileTooShort = 13,
+ FileHashMismatch = 14,
+ NetworkFailed = 20,
+ NetworkTimeout = 21,
+ NetworkDisconnected = 22,
+ NetworkServerDown = 23,
+ NetworkInvalidRequest = 24,
+ ServerFailed = 30,
+ //ServerNoRange = 31,
+ ServerBadContent = 33,
+ ServerUnauthorized = 34,
+ ServerCertProblem = 35,
+ ServerForbidden = 36,
+ ServerUnreachable = 37,
+ UserCanceled = 40,
+ //UserShutdown = 41,
+ //Crash = 50
+ };
+ Q_ENUM(DownloadInterruptReason)
+
enum DownloadType {
Attachment = 0,
DownloadAttribute,
@@ -98,6 +129,7 @@ public:
Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged REVISION 1)
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(DownloadType type READ type NOTIFY typeChanged REVISION 3 FINAL)
+ Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged REVISION 4 FINAL)
Q_INVOKABLE void accept();
Q_INVOKABLE void cancel();
@@ -112,6 +144,7 @@ public:
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
DownloadType type() const;
+ DownloadInterruptReason interruptReason() const;
Q_SIGNALS:
void stateChanged();
@@ -121,6 +154,7 @@ Q_SIGNALS:
Q_REVISION(1) void mimeTypeChanged();
void pathChanged();
Q_REVISION(3) void typeChanged();
+ Q_REVISION(4) void interruptReasonChanged();
private:
QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index 1789af462..4fb609492 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -74,6 +74,7 @@ public:
QQuickWebEngineDownloadItem::DownloadState downloadState;
QQuickWebEngineDownloadItem::SavePageFormat savePageFormat;
QQuickWebEngineDownloadItem::DownloadType type;
+ QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason;
qint64 totalBytes;
qint64 receivedBytes;
QString mimeType;
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index f8f790061..49f7b38a8 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -98,6 +98,8 @@ public:
tr("Cannot create a separate instance of WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 4>(uri, 1, 5, "WebEngineDownloadItem",
+ tr("Cannot create a separate instance of WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", msgUncreatableType("WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings"));
qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings"));
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index b777a0898..4a3371904 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -46,6 +46,34 @@ QT_BEGIN_NAMESPACE
using QtWebEngineCore::BrowserContextAdapterClient;
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NoReason, QWebEngineDownloadItem::NoReason)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileFailed, QWebEngineDownloadItem::FileFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileAccessDenied, QWebEngineDownloadItem::FileAccessDenied)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNoSpace, QWebEngineDownloadItem::FileNoSpace)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNameTooLong, QWebEngineDownloadItem::FileNameTooLong)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooLarge, QWebEngineDownloadItem::FileTooLarge)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileVirusInfected, QWebEngineDownloadItem::FileVirusInfected)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTransientError, QWebEngineDownloadItem::FileTransientError)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileBlocked, QWebEngineDownloadItem::FileBlocked)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadItem::FileSecurityCheckFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooShort, QWebEngineDownloadItem::FileTooShort)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileHashMismatch, QWebEngineDownloadItem::FileHashMismatch)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkFailed, QWebEngineDownloadItem::NetworkFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkTimeout, QWebEngineDownloadItem::NetworkTimeout)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkDisconnected, QWebEngineDownloadItem::NetworkDisconnected)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkServerDown, QWebEngineDownloadItem::NetworkServerDown)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkInvalidRequest, QWebEngineDownloadItem::NetworkInvalidRequest)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerFailed, QWebEngineDownloadItem::ServerFailed)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerNoRange, QWebEngineDownloadItem::ServerNoRange)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerBadContent, QWebEngineDownloadItem::ServerBadContent)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnauthorized, QWebEngineDownloadItem::ServerUnauthorized)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerCertProblem, QWebEngineDownloadItem::ServerCertProblem)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerForbidden, QWebEngineDownloadItem::ServerForbidden)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnreachable, QWebEngineDownloadItem::ServerUnreachable)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserCanceled, QWebEngineDownloadItem::UserCanceled)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserShutdown, QWebEngineDownloadItem::UserShutdown)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::Crash, QWebEngineDownloadItem::Crash)
+
static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state)
{
switch (state) {
@@ -63,6 +91,11 @@ static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state)
}
}
+static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
+{
+ return static_cast<QWebEngineDownloadItem::DownloadInterruptReason>(reason);
+}
+
/*!
\class QWebEngineDownloadItem
\brief The QWebEngineDownloadItem class provides information about a download.
@@ -81,6 +114,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr
, downloadState(QWebEngineDownloadItem::DownloadCancelled)
, savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
, type(QWebEngineDownloadItem::Attachment)
+ , interruptReason(QWebEngineDownloadItem::NoReason)
, downloadUrl(url)
, totalBytes(-1)
, receivedBytes(0)
@@ -97,6 +131,11 @@ void QWebEngineDownloadItemPrivate::update(const BrowserContextAdapterClient::Do
Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested);
+ if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
+ interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
+ Q_EMIT q->interruptReasonChanged();
+ }
+
if (toDownloadState(info.state) != downloadState) {
downloadState = toDownloadState(info.state);
Q_EMIT q->stateChanged(downloadState);
@@ -192,6 +231,15 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
+ \fn QWebEngineDownloadItem::interruptReasonChanged()
+ \since 5.9
+
+ This signal is emitted whenever the reason of the download's interruption changes.
+
+ \sa interruptReason(), QWebEngineDownloadItem::DownloadInterruptReason
+*/
+
+/*!
\enum QWebEngineDownloadItem::DownloadState
This enum describes the state of the download:
@@ -238,6 +286,45 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
+ \enum QWebEngineDownloadItem::DownloadInterruptReason
+ \since 5.9
+
+ Describes the reason why a download was interrupted:
+
+ \value NoReason Unknown reason or not interrupted.
+ \value FileFailed General file operation failure.
+ \value FileAccessDenied The file cannot be written locally, due to access restrictions.
+ \value FileNoSpace Insufficient space on the target drive.
+ \value FileNameTooLong The directory or file name is too long.
+ \value FileTooLarge The file size exceeds the file system limitation.
+ \value FileVirusInfected The file is infected with a virus.
+ \value FileTransientError Temporary problem (for example the file is in use,
+ out of memory, or too many files are opened at once).
+ \value FileBlocked The file was blocked due to local policy.
+ \value FileSecurityCheckFailed An attempt to check the safety of the download
+ failed due to unexpected reasons.
+ \value FileTooShort An attempt was made to seek past the end of a file when
+ opening a file (as part of resuming a previously interrupted download).
+ \value FileHashMismatch The partial file did not match the expected hash.
+
+ \value NetworkFailed General network failure.
+ \value NetworkTimeout The network operation has timed out.
+ \value NetworkDisconnected The network connection has been terminated.
+ \value NetworkServerDown The server has gone down.
+ \value NetworkInvalidRequest The network request was invalid (for example, the
+ original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
+
+ \value ServerFailed General server failure.
+ \value ServerBadContent The server does not have the requested data.
+ \value ServerUnauthorized The server did not authorize access to the resource.
+ \value ServerCertProblem A problem with the server certificate occurred.
+ \value ServerForbidden Access forbidden by the server.
+ \value ServerUnreachable Unexpected server response (might indicate that
+ the responding server may not be the intended server).
+ \value UserCanceled The user canceled the download.
+*/
+
+/*!
Returns the download item's current state.
\sa QWebEngineDownloadItem::DownloadState
@@ -374,6 +461,17 @@ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
return d->type;
}
+/*!
+ Returns the reason why the download was interrupted.
+ \since 5.9
+*/
+
+QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interruptReason() const
+{
+ Q_D(const QWebEngineDownloadItem);
+ return d->interruptReason;
+}
+
QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index 4b58748ad..6990b1e52 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -72,6 +72,37 @@ public:
};
Q_ENUM(SavePageFormat)
+ enum DownloadInterruptReason {
+ NoReason = 0,
+ FileFailed = 1,
+ FileAccessDenied = 2,
+ FileNoSpace = 3,
+ FileNameTooLong = 5,
+ FileTooLarge = 6,
+ FileVirusInfected = 7,
+ FileTransientError = 10,
+ FileBlocked = 11,
+ FileSecurityCheckFailed = 12,
+ FileTooShort = 13,
+ FileHashMismatch = 14,
+ NetworkFailed = 20,
+ NetworkTimeout = 21,
+ NetworkDisconnected = 22,
+ NetworkServerDown = 23,
+ NetworkInvalidRequest = 24,
+ ServerFailed = 30,
+ //ServerNoRange = 31,
+ ServerBadContent = 33,
+ ServerUnauthorized = 34,
+ ServerCertProblem = 35,
+ ServerForbidden = 36,
+ ServerUnreachable = 37,
+ UserCanceled = 40,
+ //UserShutdown = 41,
+ //Crash = 50
+ };
+ Q_ENUM(DownloadInterruptReason)
+
enum DownloadType {
Attachment = 0,
DownloadAttribute,
@@ -92,6 +123,7 @@ public:
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
DownloadType type() const;
+ DownloadInterruptReason interruptReason() const;
public Q_SLOTS:
void accept();
@@ -101,6 +133,7 @@ Q_SIGNALS:
void finished();
void stateChanged(QWebEngineDownloadItem::DownloadState state);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+ void interruptReasonChanged();
private:
Q_DISABLE_COPY(QWebEngineDownloadItem)
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
index 9ddb45444..038332da3 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
@@ -73,6 +73,7 @@ public:
QWebEngineDownloadItem::DownloadState downloadState;
QWebEngineDownloadItem::SavePageFormat savePageFormat;
QWebEngineDownloadItem::DownloadType type;
+ QWebEngineDownloadItem::DownloadInterruptReason interruptReason;
QString downloadPath;
const QUrl downloadUrl;
QString mimeType;