Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

void Q3LocalFs::operationPut ( Q3NetworkOperation op ) [protected, virtual]

Reimplemented from Q3NetworkProtocol.

Definition at line 329 of file q3localfs.cpp.

References Q3NetworkOperation::arg(), QFile::close(), Q3NetworkProtocol::dataTransferProgress(), Q3NetworkProtocol::finished(), QFile::flush(), QFile::open(), Q3NetworkProtocol::operationInProgress(), Q3NetworkOperation::rawArg(), Q3NetworkOperation::setErrorCode(), Q3NetworkOperation::setProtocolDetail(), Q3NetworkOperation::setState(), and QByteArray::size().

{
#ifdef QLOCALFS_DEBUG
    qDebug( "Q3LocalFs: operationPut" );
#endif
    op->setState( StInProgress );
    QString to = Q3Url( op->arg( 0 ) ).path();

    QFile f( to );
    if ( !f.open( IO_WriteOnly ) ) {
      QString msg = tr( "Could not write\n%1" ).arg( to );
      op->setState( StFailed );
      op->setProtocolDetail( msg );
      op->setErrorCode( (int)ErrPut );
      emit finished( op );
      return;
    }

    QByteArray ba( op->rawArg( 1 ) );
    emit dataTransferProgress( 0, ba.size(), op );
    int blockSize = calcBlockSize( ba.size() );
    if ( (int)ba.size() < blockSize ) {
      f.writeBlock( ba.data(), ba.size() );
      emit dataTransferProgress( ba.size(), ba.size(), op );
    } else {
      int i = 0;
      while ( i + blockSize < (int)ba.size() - 1 ) {
          if ( operationInProgress() != op )
            return;
          f.writeBlock( &ba.data()[ i ], blockSize );
          f.flush();
          emit dataTransferProgress( i + blockSize, ba.size(), op );
          i += blockSize;
          QPointer<QObject> that = this;
            qApp->processEvents();
            if (!that)
                return;
      }
      if ( i < (int)ba.size() - 1 )
          f.writeBlock( &ba.data()[ i ], ba.size() - i );
      emit dataTransferProgress( ba.size(), ba.size(), op );
    }
    op->setState( StDone );
    f.close();
    emit finished( op );
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index