20 #include "storedtransferjob.h"
22 using namespace TDEIOext;
24 #define TDEIO_ARGS TQByteArray packedArgs; TQDataStream stream( packedArgs, IO_WriteOnly ); stream
27 const TQByteArray &packedArgs,
28 const TQByteArray &_staticData,
29 bool showProgressInfo)
30 : TDEIO::TransferJob( url, command, packedArgs, _staticData, showProgressInfo ),
33 connect(
this, TQ_SIGNAL(
data( TDEIO::Job *,
const TQByteArray & ) ),
34 TQ_SLOT( slotData( TDEIO::Job *,
const TQByteArray & ) ) );
35 connect(
this, TQ_SIGNAL( dataReq( TDEIO::Job *, TQByteArray & ) ),
36 TQ_SLOT( slotDataReq( TDEIO::Job *, TQByteArray & ) ) );
41 Q_ASSERT( m_data.isNull() );
42 Q_ASSERT( m_uploadOffset == 0 );
46 void StoredTransferJob::slotData( TDEIO::Job *,
const TQByteArray &data )
49 if (
data.size() == 0 )
51 unsigned int oldSize = m_data.size();
52 m_data.resize( oldSize +
data.size(), TQGArray::SpeedOptim );
53 memcpy( m_data.data() + oldSize,
data.data(),
data.size() );
56 void StoredTransferJob::slotDataReq( TDEIO::Job *, TQByteArray &data )
60 const int MAX_CHUNK_SIZE = 64*1024;
61 int remainingBytes = m_data.size() - m_uploadOffset;
62 if( remainingBytes > MAX_CHUNK_SIZE ) {
64 data.duplicate( m_data.data() + m_uploadOffset, MAX_CHUNK_SIZE );
65 m_uploadOffset += MAX_CHUNK_SIZE;
70 data.duplicate( m_data.data() + m_uploadOffset, remainingBytes );
71 m_data = TQByteArray();
79 StoredTransferJob *TDEIOext::storedGet(
const KURL& url,
bool reload,
bool showProgressInfo )
85 job->addMetaData(
"cache",
"reload");
89 StoredTransferJob *TDEIOext::put(
const TQByteArray& arr,
const KURL& url,
int permissions,
90 bool overwrite,
bool resume,
bool showProgressInfo )
92 TDEIO_ARGS << url << TQ_INT8( overwrite ? 1 : 0 ) << TQ_INT8( resume ? 1 : 0 ) << permissions;
98 #include "storedtransferjob.moc"
StoredTransferJob is a TransferJob (for downloading or uploading data) that also stores a TQByteArray...
StoredTransferJob(const KURL &url, int command, const TQByteArray &packedArgs, const TQByteArray &_staticData, bool showProgressInfo)
Do not create a StoredTransferJob.
TQByteArray data() const
Get hold of the downloaded data.
void setData(const TQByteArray &arr)
Set data to be uploaded.