You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
4.2 KiB
115 lines
4.2 KiB
/*
|
|
Copyright (C) 2004 David Faure <faure@kde.org>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef STOREDTRANSFERJOB_H
|
|
#define STOREDTRANSFERJOB_H
|
|
|
|
#include <tdeio/job.h>
|
|
|
|
// To be moved to KIO?
|
|
namespace TDEIOext {
|
|
|
|
/**
|
|
* StoredTransferJob is a TransferJob (for downloading or uploading data) that
|
|
* also stores a TQByteArray with the data, making it simpler to use than the
|
|
* standard TransferJob.
|
|
*
|
|
* For TDEIO::get it puts the data into the member TQByteArray, so the user
|
|
* of this class can get hold of the whole data at once by calling data()
|
|
* when the result signal is emitted.
|
|
* You should only use StoredTransferJob to download data if you cannot
|
|
* process the data by chunks while it's being downloaded, since storing
|
|
* everything in a TQByteArray can potentially require a lot of memory.
|
|
*
|
|
* For TDEIO::put the user of this class simply provides the bytearray from
|
|
* the start, and the job takes care of uploading it.
|
|
* You should only use StoredTransferJob to upload data if you cannot
|
|
* provide the in chunks while it's being uploaded, since storing
|
|
* everything in a TQByteArray can potentially require a lot of memory.
|
|
*
|
|
*/
|
|
class StoredTransferJob : public TDEIO::TransferJob {
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
/**
|
|
* Do not create a StoredTransferJob. Use storedGet() or storedPut()
|
|
* instead.
|
|
* @param url the url to get or put
|
|
* @param command the command to issue
|
|
* @param packedArgs the arguments
|
|
* @param _staticData additional data to transmit (e.g. in a HTTP Post)
|
|
* @param showProgressInfo true to show progress information to the user
|
|
*/
|
|
StoredTransferJob(const KURL& url, int command,
|
|
const TQByteArray &packedArgs,
|
|
const TQByteArray &_staticData,
|
|
bool showProgressInfo);
|
|
|
|
/**
|
|
* Set data to be uploaded. This is for put jobs.
|
|
* Automatically called by TDEIOext::put(const TQByteArray &, ...), do not call this yourself.
|
|
*/
|
|
void setData( const TQByteArray& arr );
|
|
|
|
/**
|
|
* Get hold of the downloaded data. This is for get jobs.
|
|
* You're supposed to call this only from the slot connected to the result() signal.
|
|
*/
|
|
TQByteArray data() const { return m_data; }
|
|
|
|
private slots:
|
|
void slotData( TDEIO::Job *job, const TQByteArray &data );
|
|
void slotDataReq( TDEIO::Job *job, TQByteArray &data );
|
|
private:
|
|
TQByteArray m_data;
|
|
int m_uploadOffset;
|
|
};
|
|
|
|
/**
|
|
* Get (a.k.a. read), into a single TQByteArray.
|
|
* @see StoredTransferJob
|
|
*
|
|
* @param url the URL of the file
|
|
* @param reload true to reload the file, false if it can be taken from the cache
|
|
* @param showProgressInfo true to show progress information
|
|
* @return the job handling the operation.
|
|
*/
|
|
StoredTransferJob *storedGet( const KURL& url, bool reload=false, bool showProgressInfo = true );
|
|
|
|
/**
|
|
* Put (a.k.a. write) data from a single TQByteArray.
|
|
* @see StoredTransferJob
|
|
*
|
|
* @param url Where to write data.
|
|
* @param permissions May be -1. In this case no special permission mode is set.
|
|
* @param overwrite If true, any existing file will be overwritten.
|
|
* @param resume true to resume, false otherwise
|
|
* @param showProgressInfo true to show progress information
|
|
* @return the job handling the operation.
|
|
* @see multi_get()
|
|
*/
|
|
StoredTransferJob *put( const TQByteArray& arr, const KURL& url, int permissions,
|
|
bool overwrite, bool resume, bool showProgressInfo = true );
|
|
|
|
} // namespace
|
|
|
|
#endif
|