Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qnetworkreplydataimpl_p.h" | - |
43 | #include "private/qdataurl_p.h" | - |
44 | #include <QtCore/QCoreApplication> | - |
45 | #include <QtCore/QMetaObject> | - |
46 | | - |
47 | QT_BEGIN_NAMESPACE | - |
48 | | - |
49 | QNetworkReplyDataImplPrivate::QNetworkReplyDataImplPrivate() | - |
50 | : QNetworkReplyPrivate() | - |
51 | { | - |
52 | } executed: } Execution Count:30 | 30 |
53 | | - |
54 | QNetworkReplyDataImplPrivate::~QNetworkReplyDataImplPrivate() | - |
55 | { | - |
56 | } | - |
57 | | - |
58 | QNetworkReplyDataImpl::~QNetworkReplyDataImpl() | - |
59 | { | - |
60 | } | - |
61 | | - |
62 | QNetworkReplyDataImpl::QNetworkReplyDataImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op) | - |
63 | : QNetworkReply(*new QNetworkReplyDataImplPrivate(), parent) | - |
64 | { | - |
65 | Q_D(QNetworkReplyDataImpl); executed (the execution status of this line is deduced): QNetworkReplyDataImplPrivate * const d = d_func(); | - |
66 | setRequest(req); executed (the execution status of this line is deduced): setRequest(req); | - |
67 | setUrl(req.url()); executed (the execution status of this line is deduced): setUrl(req.url()); | - |
68 | setOperation(op); executed (the execution status of this line is deduced): setOperation(op); | - |
69 | setFinished(true); executed (the execution status of this line is deduced): setFinished(true); | - |
70 | QNetworkReply::open(QIODevice::ReadOnly); executed (the execution status of this line is deduced): QNetworkReply::open(QIODevice::ReadOnly); | - |
71 | | - |
72 | QUrl url = req.url(); executed (the execution status of this line is deduced): QUrl url = req.url(); | - |
73 | QString mimeType; executed (the execution status of this line is deduced): QString mimeType; | - |
74 | QByteArray payload; executed (the execution status of this line is deduced): QByteArray payload; | - |
75 | if (qDecodeDataUrl(url, mimeType, payload)) { partially evaluated: qDecodeDataUrl(url, mimeType, payload) yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
76 | qint64 size = payload.size(); executed (the execution status of this line is deduced): qint64 size = payload.size(); | - |
77 | setHeader(QNetworkRequest::ContentTypeHeader, mimeType); executed (the execution status of this line is deduced): setHeader(QNetworkRequest::ContentTypeHeader, mimeType); | - |
78 | setHeader(QNetworkRequest::ContentLengthHeader, size); executed (the execution status of this line is deduced): setHeader(QNetworkRequest::ContentLengthHeader, size); | - |
79 | QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); | - |
80 | | - |
81 | d->decodedData.setData(payload); executed (the execution status of this line is deduced): d->decodedData.setData(payload); | - |
82 | d->decodedData.open(QIODevice::ReadOnly); executed (the execution status of this line is deduced): d->decodedData.open(QIODevice::ReadOnly); | - |
83 | | - |
84 | QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection, executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection, | - |
85 | Q_ARG(qint64,size), Q_ARG(qint64, size)); executed (the execution status of this line is deduced): QArgument<qint64 >("qint64", size), QArgument<qint64 >("qint64", size)); | - |
86 | QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); | - |
87 | QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); | - |
88 | } else { executed: } Execution Count:30 | 30 |
89 | // something wrong with this URI | - |
90 | const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend", never executed (the execution status of this line is deduced): const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend", | - |
91 | "Invalid URI: %1").arg(url.toString()); never executed (the execution status of this line is deduced): "Invalid URI: %1").arg(url.toString()); | - |
92 | setError(QNetworkReply::ProtocolFailure, msg); never executed (the execution status of this line is deduced): setError(QNetworkReply::ProtocolFailure, msg); | - |
93 | QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, | - |
94 | Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolFailure)); never executed (the execution status of this line is deduced): QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::ProtocolFailure)); | - |
95 | QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); | - |
96 | } | 0 |
97 | } | - |
98 | | - |
99 | void QNetworkReplyDataImpl::close() | - |
100 | { | - |
101 | QNetworkReply::close(); never executed (the execution status of this line is deduced): QNetworkReply::close(); | - |
102 | } | 0 |
103 | | - |
104 | void QNetworkReplyDataImpl::abort() | - |
105 | { | - |
106 | QNetworkReply::close(); never executed (the execution status of this line is deduced): QNetworkReply::close(); | - |
107 | } | 0 |
108 | | - |
109 | qint64 QNetworkReplyDataImpl::bytesAvailable() const | - |
110 | { | - |
111 | Q_D(const QNetworkReplyDataImpl); executed (the execution status of this line is deduced): const QNetworkReplyDataImplPrivate * const d = d_func(); | - |
112 | return QNetworkReply::bytesAvailable() + d->decodedData.bytesAvailable(); executed: return QNetworkReply::bytesAvailable() + d->decodedData.bytesAvailable(); Execution Count:8 | 8 |
113 | } | - |
114 | | - |
115 | bool QNetworkReplyDataImpl::isSequential () const | - |
116 | { | - |
117 | return true; executed: return true; Execution Count:29 | 29 |
118 | } | - |
119 | | - |
120 | qint64 QNetworkReplyDataImpl::size() const | - |
121 | { | - |
122 | Q_D(const QNetworkReplyDataImpl); never executed (the execution status of this line is deduced): const QNetworkReplyDataImplPrivate * const d = d_func(); | - |
123 | return d->decodedData.size(); never executed: return d->decodedData.size(); | 0 |
124 | } | - |
125 | | - |
126 | /*! | - |
127 | \internal | - |
128 | */ | - |
129 | qint64 QNetworkReplyDataImpl::readData(char *data, qint64 maxlen) | - |
130 | { | - |
131 | Q_D(QNetworkReplyDataImpl); executed (the execution status of this line is deduced): QNetworkReplyDataImplPrivate * const d = d_func(); | - |
132 | | - |
133 | // TODO idea: | - |
134 | // Instead of decoding the whole data into new memory, we could decode on demand. | - |
135 | // Note that this might be tricky to do. | - |
136 | | - |
137 | return d->decodedData.read(data, maxlen); executed: return d->decodedData.read(data, maxlen); Execution Count:92 | 92 |
138 | } | - |
139 | | - |
140 | | - |
141 | QT_END_NAMESPACE | - |
142 | | - |
143 | #include "moc_qnetworkreplydataimpl_p.cpp" | - |
144 | | - |
145 | | - |
| | |