Changeset 561 for trunk/src/network/access/qnetworkaccessfilebackend.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/network/access/qnetworkaccessfilebackend.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 #include "qurlinfo.h" 45 45 #include "qdir.h" 46 46 47 47 48 #include <QtCore/QCoreApplication> … … 78 79 79 80 QNetworkAccessFileBackend::QNetworkAccessFileBackend() 80 : totalBytes(0)81 : ) 81 82 { 82 83 } … … 109 110 if (fileName.isEmpty()) { 110 111 if (url.scheme() == QLatin1String("qrc")) 111 fileName = QLatin1 String(":") + url.path();112 fileName = QLatin1) + url.path(); 112 113 else 113 114 fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); … … 127 128 case QNetworkAccessManager::PutOperation: 128 129 mode = QIODevice::WriteOnly | QIODevice::Truncate; 130 131 132 129 133 break; 130 134 default: … … 153 157 } 154 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 155 199 void QNetworkAccessFileBackend::closeDownstreamChannel() 156 200 { 157 201 if (operation() == QNetworkAccessManager::GetOperation) { 158 202 file.close(); 159 //downstreamChannelClosed();160 }161 }162 163 void QNetworkAccessFileBackend::closeUpstreamChannel()164 {165 if (operation() == QNetworkAccessManager::PutOperation) {166 file.close();167 finished();168 203 } 169 204 } … … 173 208 Q_ASSERT(operation() == QNetworkAccessManager::GetOperation); 174 209 return readMoreFromFile(); 175 }176 177 bool QNetworkAccessFileBackend::waitForUpstreamBytesWritten(int)178 {179 Q_ASSERT_X(false, "QNetworkAccessFileBackend::waitForUpstreamBytesWritten",180 "This function should never have been called, since there is never anything "181 "left to be written!");182 return false;183 }184 185 void QNetworkAccessFileBackend::upstreamReadyRead()186 {187 Q_ASSERT_X(operation() == QNetworkAccessManager::PutOperation, "QNetworkAccessFileBackend",188 "We're being told to upload data but operation isn't PUT!");189 190 // there's more data to be written to the file191 while (upstreamBytesAvailable()) {192 // write everything and let QFile handle it193 int written = file.write(readUpstream());194 195 if (written < 0) {196 // write error!197 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Write error writing to %1: %2")198 .arg(url().toString(), file.errorString());199 error(QNetworkReply::ProtocolFailure, msg);200 201 finished();202 return;203 }204 205 // successful write206 file.flush();207 upstreamBytesConsumed(written);208 }209 210 } 210 211 … … 263 264 data.resize(actuallyRead); 264 265 totalBytes += actuallyRead; 265 writeDownstreamData(data); 266 267 QByteDataBuffer list; 268 list.append(data); 269 data.clear(); // important because of implicit sharing! 270 writeDownstreamData(list); 266 271 } 267 272 return true;
Note:
See TracChangeset
for help on using the changeset viewer.