21#ifndef __tdeio_jobclasses_h__
22#define __tdeio_jobclasses_h__
27#include <tqstringlist.h>
28#include <tqguardedptr.h>
34#include <tdeio/global.h>
39#define TDEIO_COPYJOB_HAS_SETINTERACTIVE
67 class TDEIO_EXPORT Job :
public TQObject {
71 Job(
bool showProgressInfo );
86 virtual void kill(
bool quietly =
true );
94 int error()
const {
return m_error; }
110 const TQString &
errorText()
const {
return m_errorText; }
129 TQString errorString()
const;
141 TQStringList detailedErrorStrings(
const KURL *reqUrl = 0L,
142 int method = -1)
const;
152 void showErrorDialog( TQWidget * parent = 0L );
167 void setAutoErrorHandlingEnabled(
bool enable, TQWidget *parentWidget = 0 );
174 bool isAutoErrorHandlingEnabled()
const;
189 void setAutoWarningHandlingEnabled(
bool enable );
198 bool isAutoWarningHandlingEnabled()
const;
207 void setInteractive(
bool enable);
215 bool isInteractive()
const;
221 void setWindow(TQWidget *window);
228 TQWidget *window()
const;
235 void updateUserTimestamp(
unsigned long time );
247 void setParentJob(
Job* parentJob );
255 Job* parentJob()
const;
273 void addMetaData(
const TQString &key,
const TQString &value);
282 void addMetaData(
const TQMap<TQString,TQString> &values);
291 void mergeMetaData(
const TQMap<TQString,TQString> &values);
312 TQString queryMetaData(
const TQString &key);
438 virtual void addSubjob( Job *job,
bool inheritMetaData=
true );
492 unsigned long userTimestamp()
const;
499 enum { EF_TransferJobAsync = (1 << 0),
500 EF_TransferJobNeedData = (1 << 1),
501 EF_TransferJobDataSent = (1 << 2),
502 EF_ListJobUnrestricted = (1 << 3) };
505 TQPtrList<Job> subjobs;
507 TQString m_errorText;
508 unsigned long m_percent;
510 TQTimer *m_speedTimer;
511 TQGuardedPtr<TQWidget> m_window;
515 virtual void virtual_hook(
int id,
void* data );
539 SimpleJob(
const KURL&
url,
int command,
const TQByteArray &packedArgs,
540 bool showProgressInfo);
548 const KURL&
url()
const {
return m_url; }
557 virtual void kill(
bool quietly =
true );
563 virtual void putOnHold();
568 static void removeOnHold();
575 virtual void start(
Slave *slave );
587 Slave *slave()
const {
return m_slave; }
592 int command()
const {
return m_command; }
607 virtual void slotFinished( );
613 void slotWarning(
const TQString & );
620 void slotInfoMessage(
const TQString &s );
626 void slotConnected();
639 void slotSpeed(
unsigned long speed );
646 virtual void slotMetaData(
const TDEIO::MetaData &_metaData);
654 virtual void slotError(
int ,
const TQString & );
660 void slotNeedProgressId();
664 TQByteArray m_packedArgs;
670 virtual void virtual_hook(
int id,
void* data );
678 void storeSSLSessionFromJob(
const KURL &m_redirectionURL);
680 class SimpleJobPrivate* d;
699 StatJob(
const KURL&
url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
708 void setSide(
bool source ) { m_bSource = source; }
719 void setDetails(
short int details ) { m_details = details; }
734 virtual void start(
Slave *slave );
758 void slotRedirection(
const KURL &
url);
759 virtual void slotFinished();
764 KURL m_redirectionURL;
768 virtual void virtual_hook(
int id,
void* data );
770 class StatJobPrivate;
791 MkdirJob(
const KURL&
url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
799 virtual void start(
Slave *slave );
821 void slotRedirection(
const KURL &
url);
822 virtual void slotFinished();
825 KURL m_redirectionURL;
828 virtual void virtual_hook(
int id,
void* data );
830 class MkdirJobPrivate;
838 class TDEIO_EXPORT DirectCopyJob :
public SimpleJob {
845 DirectCopyJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
846 bool showProgressInfo);
853 virtual void start(
Slave *slave);
888 const TQByteArray &packedArgs,
889 const TQByteArray &_staticData,
890 bool showProgressInfo);
898 virtual void start(
Slave *slave);
939 void setAsyncDataEnabled(
bool enabled);
947 void sendAsyncData(
const TQByteArray &data);
956 void setReportDataSent(
bool enabled);
964 bool reportDataSent();
1028 virtual void slotRedirection(
const KURL &
url);
1029 virtual void slotFinished();
1030 virtual void slotData(
const TQByteArray &
data);
1031 virtual void slotDataReq();
1032 virtual void slotMimetype(
const TQString &
mimetype );
1033 virtual void slotNeedSubURLData();
1034 virtual void slotSubURLData(
TDEIO::Job*,
const TQByteArray &);
1036 void slotErrorPage();
1038 void slotPostRedirection();
1043 TQByteArray staticData;
1044 KURL m_redirectionURL;
1045 KURL::List m_redirectionList;
1046 TQString m_mimetype;
1049 virtual void virtual_hook(
int id,
void*
data );
1051 class TransferJobPrivate *d;
1088 const TQByteArray &packedArgs,
1089 const TQByteArray &_staticData,
1090 bool showProgressInfo);
1097 void setData(
const TQByteArray& arr );
1103 TQByteArray
data()
const {
return m_data; }
1106 void slotStoredData(
TDEIO::Job *job,
const TQByteArray &data );
1107 void slotStoredDataReq(
TDEIO::Job *job, TQByteArray &data );
1138 virtual void start(
Slave *slave);
1175 virtual void slotRedirection(
const KURL &
url);
1176 virtual void slotFinished();
1177 virtual void slotData(
const TQByteArray &
data);
1178 virtual void slotMimetype(
const TQString &
mimetype );
1182 GetRequest(
long _id,
const KURL &_url,
const MetaData &_metaData)
1188 bool findCurrentEntry();
1189 void flushQueue(TQPtrList<GetRequest> &queue);
1191 TQPtrList<GetRequest> m_waitQueue;
1192 TQPtrList<GetRequest> m_activeQueue;
1193 bool b_multiGetActive;
1194 GetRequest *m_currentEntry;
1196 virtual void virtual_hook(
int id,
void* data );
1198 class MultiGetJobPrivate* d;
1219 MimetypeJob(
const KURL&
url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
1234 virtual void start(
Slave *slave );
1237 virtual void slotFinished( );
1239 virtual void virtual_hook(
int id,
void* data );
1241 class MimetypeJobPrivate* d;
1264 FileCopyJob(
const KURL& src,
const KURL& dest,
int permissions,
1265 bool move,
bool overwrite,
bool resume,
bool showProgressInfo);
1316 void slotData(
TDEIO::Job *,
const TQByteArray &data);
1317 void slotDataReq(
TDEIO::Job *, TQByteArray &data);
1318 void slotMimetype(
TDEIO::Job *,
const TQString& type );
1353 void startCopyJob();
1354 void startCopyJob(
const KURL &slave_url);
1355 void startRenameJob(
const KURL &slave_url);
1356 void startDataPump();
1360 void startBestCopyMethod();
1370 bool m_resumeAnswerSent:1;
1371 TQByteArray m_buffer;
1378 virtual void virtual_hook(
int id,
void* data );
1380 class FileCopyJobPrivate;
1381 FileCopyJobPrivate* d;
1405 ListJob(
const KURL&
url,
bool showProgressInfo,
1406 bool recursive =
false, TQString prefix = TQString::null,
1407 bool includeHidden =
true);
1415 virtual void start(
Slave *slave );
1429 void setUnrestricted(
bool unrestricted);
1463 virtual void slotFinished( );
1466 void slotListEntries(
const TDEIO::UDSEntryList& list );
1467 void slotRedirection(
const KURL &
url );
1468 void gotEntries(
TDEIO::Job * subjob,
const TDEIO::UDSEntryList& list );
1474 unsigned long m_processedEntries;
1475 KURL m_redirectionURL;
1477 virtual void virtual_hook(
int id,
void* data );
1479 class ListJobPrivate* d;
1483 struct TDEIO_EXPORT CopyInfo
1533 CopyJob(
const KURL::List& src,
const KURL& dest, CopyMode mode,
bool asMethod,
bool showProgressInfo );
1559 void setDefaultPermissions(
bool b );
1572 void setInteractive(
bool b );
1674 void statCurrentSrc();
1679 void startListing(
const KURL & src );
1680 void slotResultCreatingDirs(
TDEIO::Job * job );
1681 void slotResultConflictCreatingDirs(
TDEIO::Job * job );
1682 void createNextDir();
1683 void slotResultCopyingFiles(
TDEIO::Job * job );
1684 void slotResultConflictCopyingFiles(
TDEIO::Job * job );
1685 void copyNextFile();
1686 void slotResultDeletingDirs(
TDEIO::Job * job );
1687 void deleteNextDir();
1688 void skip(
const KURL & sourceURL );
1691 void setNextDirAttribute();
1693 void startRenameJob(
const KURL &slave_url);
1694 bool shouldOverwrite(
const TQString& path )
const;
1695 bool shouldSkip(
const TQString& path )
const;
1700 void slotEntries(
TDEIO::Job*,
const TDEIO::UDSEntryList& list );
1716 enum DestinationState { DEST_NOT_STATED, DEST_IS_DIR, DEST_IS_FILE, DEST_DOESNT_EXIST };
1717 DestinationState destinationState;
1718 enum { STATE_STATING, STATE_RENAMING, STATE_LISTING, STATE_CREATING_DIRS,
1719 STATE_CONFLICT_CREATING_DIRS, STATE_COPYING_FILES, STATE_CONFLICT_COPYING_FILES,
1720 STATE_DELETING_DIRS, STATE_SETTING_DIR_ATTRIBUTES } state;
1724 int m_processedFiles;
1725 int m_processedDirs;
1726 TQValueList<CopyInfo> files;
1727 TQValueList<CopyInfo> dirs;
1728 KURL::List dirsToRemove;
1729 KURL::List m_srcList;
1730 KURL::List::Iterator m_currentStatSrc;
1731 bool m_bCurrentSrcIsDir;
1732 bool m_bCurrentOperationIsLink;
1733 bool m_bSingleFileCopy;
1734 bool m_bOnlyRenames;
1738 TQStringList m_skipList;
1739 TQStringList m_overwriteList;
1741 bool m_bOverwriteAll;
1742 int m_conflictError;
1744 TQTimer *m_reportTimer;
1746 KURL m_currentSrcURL;
1747 KURL m_currentDestURL;
1749 virtual void virtual_hook(
int id,
void* data );
1751 class CopyJobPrivate;
1753 friend class CopyJobPrivate;
1775 DeleteJob(
const KURL::List& src,
bool shred,
bool showProgressInfo );
1781 KURL::List
urls()
const {
return m_srcList; }
1821 void slotEntries(
TDEIO::Job*,
const TDEIO::UDSEntryList& list );
1832 void deleteNextFile();
1833 void deleteNextDir();
1836 enum { STATE_STATING, STATE_LISTING,
1837 STATE_DELETING_FILES, STATE_DELETING_DIRS } state;
1841 int m_processedFiles;
1842 int m_processedDirs;
1843 int m_totalFilesDirs;
1846 KURL::List symlinks;
1848 KURL::List m_srcList;
1849 KURL::List::Iterator m_currentStat;
1850 TQStringList m_parentDirs;
1852 TQTimer *m_reportTimer;
1855 virtual void virtual_hook(
int id,
void* data );
1857 class DeleteJobPrivate* d;
1877 LocalURLJob(
const KURL&
url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
1885 virtual void start(
Slave *slave );
1896 void slotLocalURL(
const KURL &
url,
bool isLocal );
1897 virtual void slotFinished();
1900 virtual void virtual_hook(
int id,
void* data );
1902 class LocalURLJobPrivate;
1903 LocalURLJobPrivate *d;
Observer for TDEIO::Job progress information.
CopyJob is used to move, copy or symlink files and directories.
void renamed(TDEIO::Job *job, const KURL &from, const KURL &to)
void copyingLinkDone(TDEIO::Job *job, const KURL &from, const TQString &target, const KURL &to)
CopyMode
Defines the mode of the operation.
void aboutToCreate(TDEIO::Job *job, const TQValueList< TDEIO::CopyInfo > &files)
Emitted when it is known which files / directories are going to be created.
void processedFiles(TDEIO::Job *job, unsigned long files)
Sends the number of processed files.
void moving(TDEIO::Job *job, const KURL &from, const KURL &to)
KURL destURL() const
Returns the destination URL.
void linking(TDEIO::Job *job, const TQString &target, const KURL &to)
KURL::List srcURLs() const
Returns the list of source URLs.
void copyingDone(TDEIO::Job *job, const KURL &from, const KURL &to, bool directory, bool renamed)
CopyJob(const KURL::List &src, const KURL &dest, CopyMode mode, bool asMethod, bool showProgressInfo)
Do not create a CopyJob directly.
void totalDirs(TDEIO::Job *job, unsigned long dirs)
Emitted when the toal number of direcotries is known.
void creatingDir(TDEIO::Job *job, const KURL &dir)
void slotTotalSize(TDEIO::Job *, TDEIO::filesize_t size)
void slotProcessedSize(TDEIO::Job *, TDEIO::filesize_t data_size)
Forward signal from subjob.
void totalFiles(TDEIO::Job *job, unsigned long files)
Emitted when the total number of files is known.
void processedDirs(TDEIO::Job *job, unsigned long dirs)
Sends the number of processed directories.
void copying(TDEIO::Job *job, const KURL &from, const KURL &to)
void totalDirs(TDEIO::Job *job, unsigned long dirs)
Emitted when the toal number of direcotries is known.
void processedDirs(TDEIO::Job *job, unsigned long dirs)
Sends the number of processed directories.
DeleteJob(const KURL::List &src, bool shred, bool showProgressInfo)
Do not create a DeleteJob directly.
void processedFiles(TDEIO::Job *job, unsigned long files)
Sends the number of processed files.
void deleting(TDEIO::Job *job, const KURL &file)
Sends the URL of the file that is currently being deleted.
KURL::List urls() const
Returns the list of URLs.
void slotProcessedSize(TDEIO::Job *, TDEIO::filesize_t data_size)
Forward signal from subjob.
void totalFiles(TDEIO::Job *job, unsigned long files)
Emitted when the total number of files is known.
void slotCanResume(TDEIO::Job *job, TDEIO::filesize_t offset)
void slotPercent(TDEIO::Job *job, unsigned long pct)
virtual void slotResult(TDEIO::Job *job)
void slotProcessedSize(TDEIO::Job *job, TDEIO::filesize_t size)
FileCopyJob(const KURL &src, const KURL &dest, int permissions, bool move, bool overwrite, bool resume, bool showProgressInfo)
Do not create a FileCopyJob directly.
void setSourceSize64(TDEIO::filesize_t size)
KURL destURL() const
Returns the destination URL.
void slotTotalSize(TDEIO::Job *job, TDEIO::filesize_t size)
void setSourceSize(off_t size) TDE_DEPRECATED
void setModificationTime(time_t mtime)
Sets the modification time of the file.
KURL srcURL() const
Returns the source URL.
void mimetype(TDEIO::Job *job, const TQString &type)
Mimetype determined during a file copy.
The base class for all jobs.
virtual void removeSubjob(Job *job)
virtual void slotResult(TDEIO::Job *job)
void mergeMetaData(const TQMap< TQString, TQString > &values)
void setProcessedSize(TDEIO::filesize_t size)
Set the processed size, does not emit processedSize.
void emitResult()
Utility function to emit the result signal, and suicide this job.
virtual void addSubjob(Job *job, bool inheritMetaData=true)
void emitSpeed(unsigned long speed)
void slotSpeed(TDEIO::Job *job, unsigned long speed)
const TQString & errorText() const
Returns the error text if there has been an error.
void result(TDEIO::Job *job)
int progressId() const
Returns the progress id for this job.
void infoMessage(TDEIO::Job *job, const TQString &msg)
void connected(TDEIO::Job *job)
virtual void kill(bool quietly=true)
Abort this job.
void totalSize(TDEIO::Job *job, TDEIO::filesize_t size)
void slotSpeedTimeout()
Remove speed information.
void speed(TDEIO::Job *job, unsigned long speed)
void emitPercent(TDEIO::filesize_t processedSize, TDEIO::filesize_t totalSize)
int error() const
Returns the error code, if there has been an error.
void canceled(TDEIO::Job *job)
void percent(TDEIO::Job *job, unsigned long percent)
void slotInfoMessage(TDEIO::Job *job, const TQString &msg)
MetaData metaData() const
void warning(TDEIO::Job *job, const TQString &msg)
Emitted to display a warning about this job, as sent by the slave.
void processedSize(TDEIO::Job *job, TDEIO::filesize_t size)
void redirection(TDEIO::Job *job, const KURL &url)
void entries(TDEIO::Job *job, const TDEIO::UDSEntryList &list)
const KURL & redirectionURL() const
Returns the ListJob's redirection URL.
void permanentRedirection(TDEIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
ListJob(const KURL &url, bool showProgressInfo, bool recursive=false, TQString prefix=TQString::null, bool includeHidden=true)
Do not create a ListJob directly.
A TDEIO job that finds a local URL.
void localURL(TDEIO::LocalURLJob *job, const KURL &url, bool isLocal)
LocalURLJob(const KURL &url, int command, const TQByteArray &packedArgs, bool showProgressInfo)
Do not use this constructor to create a LocalURLJob, use TDEIO::localURL() instead.
MimetypeJob(const KURL &url, int command, const TQByteArray &packedArgs, bool showProgressInfo)
Do not create a MimetypeJob directly.
TQString mimetype() const
void redirection(TDEIO::Job *job, const KURL &url)
void permanentRedirection(TDEIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
MkdirJob(const KURL &url, int command, const TQByteArray &packedArgs, bool showProgressInfo)
Do not use this constructor to create a MkdirJob, use TDEIO::mkdir() instead.
void mimetype(long id, const TQString &type)
void get(long id, const KURL &url, const MetaData &metaData)
Get an additional file.
void data(long id, const TQByteArray &data)
MultiGetJob(const KURL &url, bool showProgressInfo)
Do not create a MultiGetJob directly, use TDEIO::multi_get() instead.
A simple job (one url and one command).
const KURL & url() const
Returns the SimpleJob's URL.
SimpleJob(const KURL &url, int command, const TQByteArray &packedArgs, bool showProgressInfo)
Creates a new simple job.
There are two classes that specifies the protocol between application (TDEIO::Job) and tdeioslave.
Attention developers: If you change the implementation of TDEIO::Slave, do not use connection() or sl...
void redirection(TDEIO::Job *job, const KURL &url)
void setSide(bool source)
A stat() can have two meanings.
StatJob(const KURL &url, int command, const TQByteArray &packedArgs, bool showProgressInfo)
Do not use this constructor to create a StatJob, use TDEIO::stat() instead.
void permanentRedirection(TDEIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
const UDSEntry & statResult() const
void setDetails(short int details)
TQByteArray data() const
Get hold of the downloaded data.
StoredTransferJob(const KURL &url, int command, const TQByteArray &packedArgs, const TQByteArray &_staticData, bool showProgressInfo)
Do not create a StoredTransferJob.
void setData(const TQByteArray &arr)
Set data to be uploaded.
The transfer job pumps data into and/or out of a Slave.
void data(TDEIO::Job *job, const TQByteArray &data)
Data from the slave has arrived.
void mimetype(TDEIO::Job *job, const TQString &type)
void resume()
Flow control.
virtual void slotResult(TDEIO::Job *job)
void redirection(TDEIO::Job *job, const KURL &url)
TransferJob(const KURL &url, int command, const TQByteArray &packedArgs, const TQByteArray &_staticData, bool showProgressInfo)
Do not create a TransferJob.
void permanentRedirection(TDEIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
bool isErrorPage() const
Checks whether we got an error page.
void dataReq(TDEIO::Job *job, TQByteArray &data)
void suspend()
Flow control.
A namespace for TDEIO globals.
TDEIO_EXPORT CopyJob * move(const KURL &src, const KURL &dest, bool showProgressInfo=true)
Moves a file or directory src to the given destination dest.
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
TQ_ULLONG filesize_t
64-bit file size