Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/access/qnetworkaccessfilebackend.cpp

    r2 r561  
    22**
    33** 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])
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444#include "qurlinfo.h"
    4545#include "qdir.h"
     46
    4647
    4748#include <QtCore/QCoreApplication>
     
    7879
    7980QNetworkAccessFileBackend::QNetworkAccessFileBackend()
    80     : totalBytes(0)
     81    : )
    8182{
    8283}
     
    109110    if (fileName.isEmpty()) {
    110111        if (url.scheme() == QLatin1String("qrc"))
    111             fileName = QLatin1String(":") + url.path();
     112            fileName = QLatin1) + url.path();
    112113        else
    113114            fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);
     
    127128    case QNetworkAccessManager::PutOperation:
    128129        mode = QIODevice::WriteOnly | QIODevice::Truncate;
     130
     131
     132
    129133        break;
    130134    default:
     
    153157}
    154158
     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
    155199void QNetworkAccessFileBackend::closeDownstreamChannel()
    156200{
    157201    if (operation() == QNetworkAccessManager::GetOperation) {
    158202        file.close();
    159         //downstreamChannelClosed();
    160     }
    161 }
    162 
    163 void QNetworkAccessFileBackend::closeUpstreamChannel()
    164 {
    165     if (operation() == QNetworkAccessManager::PutOperation) {
    166         file.close();
    167         finished();
    168203    }
    169204}
     
    173208    Q_ASSERT(operation() == QNetworkAccessManager::GetOperation);
    174209    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 file
    191     while (upstreamBytesAvailable()) {
    192         // write everything and let QFile handle it
    193         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 write
    206         file.flush();
    207         upstreamBytesConsumed(written);
    208     }
    209210}
    210211
     
    263264        data.resize(actuallyRead);
    264265        totalBytes += actuallyRead;
    265         writeDownstreamData(data);
     266
     267        QByteDataBuffer list;
     268        list.append(data);
     269        data.clear(); // important because of implicit sharing!
     270        writeDownstreamData(list);
    266271    }
    267272    return true;
Note: See TracChangeset for help on using the changeset viewer.