22 #ifndef __tdeio_jobclasses_h__ 23 #define __tdeio_jobclasses_h__ 26 #include <tqptrlist.h> 28 #include <tqstringlist.h> 29 #include <tqguardedptr.h> 31 #include <sys/types.h> 35 #include <tdeio/global.h> 40 #define TDEIO_COPYJOB_HAS_SETINTERACTIVE // new in 3.4. Used by tdeio_trash. 68 class TDEIO_EXPORT
Job :
public TQObject {
72 Job(
bool showProgressInfo );
87 virtual void kill(
bool quietly =
true );
95 int error()
const {
return m_error; }
111 const TQString &
errorText()
const {
return m_errorText; }
130 TQString errorString()
const;
142 TQStringList detailedErrorStrings(
const KURL *reqUrl = 0L,
143 int method = -1)
const;
153 void showErrorDialog( TQWidget * parent = 0L );
168 void setAutoErrorHandlingEnabled(
bool enable, TQWidget *parentWidget = 0 );
175 bool isAutoErrorHandlingEnabled()
const;
190 void setAutoWarningHandlingEnabled(
bool enable );
199 bool isAutoWarningHandlingEnabled()
const;
208 void setInteractive(
bool enable);
216 bool isInteractive()
const;
222 void setWindow(TQWidget *window);
229 TQWidget *window()
const;
236 void updateUserTimestamp(
unsigned long time );
248 void setParentJob(
Job* parentJob );
256 Job* parentJob()
const;
274 void addMetaData(
const TQString &key,
const TQString &value);
283 void addMetaData(
const TQMap<TQString,TQString> &values);
292 void mergeMetaData(
const TQMap<TQString,TQString> &values);
313 TQString queryMetaData(
const TQString &key);
345 void infoMessage(
TDEIO::Job *job,
const TQString & msg );
354 void warning(
TDEIO::Job *job,
const TQString & msg );
373 void percent(
TDEIO::Job *job,
unsigned long percent );
396 void speed(
TDEIO::Job *job,
unsigned long speed );
415 void slotSpeed(
TDEIO::Job *job,
unsigned long speed );
422 void slotInfoMessage(
TDEIO::Job *job,
const TQString &msg );
427 void slotSpeedTimeout();
439 virtual void addSubjob(
Job *job,
bool inheritMetaData=
true );
449 virtual void removeSubjob(
Job *job );
458 void removeSubjob(
Job *job,
bool mergeMetaData,
bool emitResultIfLast );
476 void emitSpeed(
unsigned long speed );
493 unsigned long userTimestamp()
const;
500 enum { EF_TransferJobAsync = (1 << 0),
501 EF_TransferJobNeedData = (1 << 1),
502 EF_TransferJobDataSent = (1 << 2),
503 EF_ListJobUnrestricted = (1 << 3) };
506 TQPtrList<Job> subjobs;
508 TQString m_errorText;
509 unsigned long m_percent;
511 TQTimer *m_speedTimer;
512 TQGuardedPtr<TQWidget> m_window;
516 virtual void virtual_hook(
int id,
void* data );
540 SimpleJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
541 bool showProgressInfo);
549 const KURL&
url()
const {
return m_url; }
558 virtual void kill(
bool quietly =
true );
564 virtual void putOnHold();
569 static void removeOnHold();
576 virtual void start(
Slave *slave );
588 Slave *slave()
const {
return m_slave; }
593 int command()
const {
return m_command; }
608 virtual void slotFinished( );
614 void slotWarning(
const TQString & );
621 void slotInfoMessage(
const TQString &s );
627 void slotConnected();
640 void slotSpeed(
unsigned long speed );
655 virtual void slotError(
int ,
const TQString & );
661 void slotNeedProgressId();
665 TQByteArray m_packedArgs;
671 virtual void virtual_hook(
int id,
void* data );
679 void storeSSLSessionFromJob(
const KURL &m_redirectionURL);
681 class SimpleJobPrivate* d;
700 StatJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
709 void setSide(
bool source ) { m_bSource = source; }
720 void setDetails(
short int details ) { m_details = details; }
735 virtual void start(
Slave *slave );
745 void redirection(
TDEIO::Job *job,
const KURL &url );
755 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
759 void slotRedirection(
const KURL &url);
760 virtual void slotFinished();
765 KURL m_redirectionURL;
769 virtual void virtual_hook(
int id,
void* data );
771 class StatJobPrivate;
792 MkdirJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
800 virtual void start(
Slave *slave );
810 void redirection(
TDEIO::Job *job,
const KURL &url );
819 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
822 void slotRedirection(
const KURL &url);
823 virtual void slotFinished();
826 KURL m_redirectionURL;
829 virtual void virtual_hook(
int id,
void* data );
831 class MkdirJobPrivate;
839 class TDEIO_EXPORT DirectCopyJob :
public SimpleJob {
846 DirectCopyJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
847 bool showProgressInfo);
854 virtual void start(
Slave *slave);
889 const TQByteArray &packedArgs,
890 const TQByteArray &_staticData,
891 bool showProgressInfo);
899 virtual void start(
Slave *slave);
940 void setAsyncDataEnabled(
bool enabled);
948 void sendAsyncData(
const TQByteArray &data);
957 void setReportDataSent(
bool enabled);
965 bool reportDataSent();
977 void data(
TDEIO::Job *job,
const TQByteArray &data );
990 void dataReq(
TDEIO::Job *job, TQByteArray &data );
999 void redirection(
TDEIO::Job *job,
const KURL &url );
1009 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
1029 virtual void slotRedirection(
const KURL &url);
1030 virtual void slotFinished();
1031 virtual void slotData(
const TQByteArray &data);
1032 virtual void slotDataReq();
1033 virtual void slotMimetype(
const TQString &mimetype );
1034 virtual void slotNeedSubURLData();
1035 virtual void slotSubURLData(
TDEIO::Job*,
const TQByteArray &);
1037 void slotErrorPage();
1039 void slotPostRedirection();
1044 TQByteArray staticData;
1045 KURL m_redirectionURL;
1046 KURL::List m_redirectionList;
1047 TQString m_mimetype;
1050 virtual void virtual_hook(
int id,
void* data );
1052 class TransferJobPrivate *d;
1089 const TQByteArray &packedArgs,
1090 const TQByteArray &_staticData,
1091 bool showProgressInfo);
1098 void setData(
const TQByteArray& arr );
1104 TQByteArray
data()
const {
return m_data; }
1107 void slotStoredData(
TDEIO::Job *job,
const TQByteArray &data );
1108 void slotStoredDataReq(
TDEIO::Job *job, TQByteArray &data );
1131 MultiGetJob(
const KURL& url,
bool showProgressInfo);
1139 virtual void start(
Slave *slave);
1148 void get(
long id,
const KURL &url,
const MetaData &metaData);
1157 void data(
long id,
const TQByteArray &data);
1164 void mimetype(
long id,
const TQString &type );
1173 void result(
long id);
1176 virtual void slotRedirection(
const KURL &url);
1177 virtual void slotFinished();
1178 virtual void slotData(
const TQByteArray &data);
1179 virtual void slotMimetype(
const TQString &mimetype );
1183 GetRequest(
long _id,
const KURL &_url,
const MetaData &_metaData)
1184 : id(_id), url(_url), metaData(_metaData) { }
1189 bool findCurrentEntry();
1190 void flushQueue(TQPtrList<GetRequest> &queue);
1192 TQPtrList<GetRequest> m_waitQueue;
1193 TQPtrList<GetRequest> m_activeQueue;
1194 bool b_multiGetActive;
1195 GetRequest *m_currentEntry;
1197 virtual void virtual_hook(
int id,
void* data );
1199 class MultiGetJobPrivate* d;
1220 MimetypeJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
1235 virtual void start(
Slave *slave );
1238 virtual void slotFinished( );
1240 virtual void virtual_hook(
int id,
void* data );
1242 class MimetypeJobPrivate* d;
1265 FileCopyJob(
const KURL& src,
const KURL& dest,
int permissions,
1266 bool move,
bool overwrite,
bool resume,
bool showProgressInfo);
1284 void setModificationTime( time_t mtime );
1289 void setSourceSize( off_t size ) KDE_DEPRECATED;
1317 void slotData(
TDEIO::Job *,
const TQByteArray &data);
1318 void slotDataReq(
TDEIO::Job *, TQByteArray &data);
1319 void slotMimetype(
TDEIO::Job *,
const TQString& type );
1345 void slotPercent(
TDEIO::Job *job,
unsigned long pct );
1354 void startCopyJob();
1355 void startCopyJob(
const KURL &slave_url);
1356 void startRenameJob(
const KURL &slave_url);
1357 void startDataPump();
1361 void startBestCopyMethod();
1371 bool m_resumeAnswerSent:1;
1372 TQByteArray m_buffer;
1379 virtual void virtual_hook(
int id,
void* data );
1381 class FileCopyJobPrivate;
1382 FileCopyJobPrivate* d;
1406 ListJob(
const KURL& url,
bool showProgressInfo,
1407 bool recursive =
false, TQString prefix = TQString::null,
1408 bool includeHidden =
true);
1416 virtual void start(
Slave *slave );
1430 void setUnrestricted(
bool unrestricted);
1442 void entries(
TDEIO::Job *job,
const TDEIO::UDSEntryList& list);
1451 void redirection(
TDEIO::Job *job,
const KURL &url );
1461 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
1464 virtual void slotFinished( );
1467 void slotListEntries(
const TDEIO::UDSEntryList& list );
1468 void slotRedirection(
const KURL &url );
1469 void gotEntries(
TDEIO::Job * subjob,
const TDEIO::UDSEntryList& list );
1475 unsigned long m_processedEntries;
1476 KURL m_redirectionURL;
1478 virtual void virtual_hook(
int id,
void* data );
1480 class ListJobPrivate* d;
1484 struct TDEIO_EXPORT CopyInfo
1534 CopyJob(
const KURL::List& src,
const KURL& dest,
CopyMode mode,
bool asMethod,
bool showProgressInfo );
1560 void setDefaultPermissions(
bool b );
1573 void setInteractive(
bool b );
1582 void totalFiles(
TDEIO::Job *job,
unsigned long files );
1588 void totalDirs(
TDEIO::Job *job,
unsigned long dirs );
1597 void aboutToCreate(
TDEIO::Job *job,
const TQValueList<TDEIO::CopyInfo> &files);
1604 void processedFiles(
TDEIO::Job *job,
unsigned long files );
1610 void processedDirs(
TDEIO::Job *job,
unsigned long dirs );
1619 void copying(
TDEIO::Job *job,
const KURL& from,
const KURL& to );
1627 void linking(
TDEIO::Job *job,
const TQString& target,
const KURL& to );
1635 void moving(
TDEIO::Job *job,
const KURL& from,
const KURL& to );
1641 void creatingDir(
TDEIO::Job *job,
const KURL& dir );
1648 void renamed(
TDEIO::Job *job,
const KURL& from,
const KURL& to );
1662 void copyingDone(
TDEIO::Job *job,
const KURL &from,
const KURL &to,
bool directory,
bool renamed );
1672 void copyingLinkDone(
TDEIO::Job *job,
const KURL &from,
const TQString& target,
const KURL& to );
1675 void statCurrentSrc();
1680 void startListing(
const KURL & src );
1681 void slotResultCreatingDirs(
TDEIO::Job * job );
1682 void slotResultConflictCreatingDirs(
TDEIO::Job * job );
1683 void createNextDir();
1684 void slotResultCopyingFiles(
TDEIO::Job * job );
1685 void slotResultConflictCopyingFiles(
TDEIO::Job * job );
1686 void copyNextFile();
1687 void slotResultDeletingDirs(
TDEIO::Job * job );
1688 void deleteNextDir();
1689 void skip(
const KURL & sourceURL );
1692 void setNextDirAttribute();
1694 void startRenameJob(
const KURL &slave_url);
1695 bool shouldOverwrite(
const TQString& path )
const;
1696 bool shouldSkip(
const TQString& path )
const;
1701 void slotEntries(
TDEIO::Job*,
const TDEIO::UDSEntryList& list );
1717 enum DestinationState { DEST_NOT_STATED, DEST_IS_DIR, DEST_IS_FILE, DEST_DOESNT_EXIST };
1718 DestinationState destinationState;
1719 enum { STATE_STATING, STATE_RENAMING, STATE_LISTING, STATE_CREATING_DIRS,
1720 STATE_CONFLICT_CREATING_DIRS, STATE_COPYING_FILES, STATE_CONFLICT_COPYING_FILES,
1721 STATE_DELETING_DIRS, STATE_SETTING_DIR_ATTRIBUTES } state;
1725 int m_processedFiles;
1726 int m_processedDirs;
1727 TQValueList<CopyInfo> files;
1728 TQValueList<CopyInfo> dirs;
1729 KURL::List dirsToRemove;
1730 KURL::List m_srcList;
1731 KURL::List::Iterator m_currentStatSrc;
1732 bool m_bCurrentSrcIsDir;
1733 bool m_bCurrentOperationIsLink;
1734 bool m_bSingleFileCopy;
1735 bool m_bOnlyRenames;
1739 TQStringList m_skipList;
1740 TQStringList m_overwriteList;
1742 bool m_bOverwriteAll;
1743 int m_conflictError;
1745 TQTimer *m_reportTimer;
1747 KURL m_currentSrcURL;
1748 KURL m_currentDestURL;
1750 virtual void virtual_hook(
int id,
void* data );
1752 class CopyJobPrivate;
1754 friend class CopyJobPrivate;
1776 DeleteJob(
const KURL::List& src,
bool shred,
bool showProgressInfo );
1782 KURL::List
urls()
const {
return m_srcList; }
1791 void totalFiles(
TDEIO::Job *job,
unsigned long files );
1797 void totalDirs(
TDEIO::Job *job,
unsigned long dirs );
1804 void processedFiles(
TDEIO::Job *job,
unsigned long files );
1810 void processedDirs(
TDEIO::Job *job,
unsigned long dirs );
1818 void deleting(
TDEIO::Job *job,
const KURL& file );
1822 void slotEntries(
TDEIO::Job*,
const TDEIO::UDSEntryList& list );
1833 void deleteNextFile();
1834 void deleteNextDir();
1837 enum { STATE_STATING, STATE_LISTING,
1838 STATE_DELETING_FILES, STATE_DELETING_DIRS } state;
1842 int m_processedFiles;
1843 int m_processedDirs;
1844 int m_totalFilesDirs;
1847 KURL::List symlinks;
1849 KURL::List m_srcList;
1850 KURL::List::Iterator m_currentStat;
1851 TQStringList m_parentDirs;
1853 TQTimer *m_reportTimer;
1856 virtual void virtual_hook(
int id,
void* data );
1858 class DeleteJobPrivate* d;
1878 LocalURLJob(
const KURL& url,
int command,
const TQByteArray &packedArgs,
bool showProgressInfo);
1886 virtual void start(
Slave *slave );
1897 void slotLocalURL(
const KURL &url,
bool isLocal );
1898 virtual void slotFinished();
1901 virtual void virtual_hook(
int id,
void* data );
1903 class LocalURLJobPrivate;
1904 LocalURLJobPrivate *d;
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
KURL srcURL() const
Returns the source URL.
KURL destURL() const
Returns the destination URL.
StoredTransferJob is a TransferJob (for downloading or uploading data) that also stores a TQByteArray...
const KURL & url() const
Returns the SimpleJob's URL.
TDEIO_EXPORT CopyJob * move(const KURL &src, const KURL &dest, bool showProgressInfo=true)
Moves a file or directory src to the given destination dest.
A TDEIO job that creates a directory.
A namespace for TDEIO globals.
void setSide(bool source)
A stat() can have two meanings.
The MultiGetJob is a TransferJob that allows you to get several files from a single server...
The base class for all jobs.
A TDEIO job that retrieves information about a file or directory.
KURL destURL() const
Returns the destination URL.
int progressId() const
Returns the progress id for this job.
TDEIO_EXPORT LocalURLJob * localURL(const KURL &remoteUrl)
Retrieve local URL if available.
int error() const
Returns the error code, if there has been an error.
TDEIO_EXPORT MimetypeJob * mimetype(const KURL &url, bool showProgressInfo=true)
Find mimetype for one file or directory.
bool isErrorPage() const
Checks whether we got an error page.
A TDEIO job that finds a local URL.
CopyJob is used to move, copy or symlink files and directories.
Observer for TDEIO::Job progress information.
TQString mimetype() const
Call this in the slot connected to result, and only after making sure no error happened.
void setDetails(short int details)
Selects the level of details we want.
const UDSEntry & statResult() const
Call this in the slot connected to result, and only after making sure no error happened.
A simple job (one url and one command).
const TQString & errorText() const
Returns the error text if there has been an error.
A more complex Job to delete files and directories.
A ListJob is allows you to get the get the content of a directory.
CopyMode
Defines the mode of the operation.
Attention developers: If you change the implementation of TDEIO::Slave, do not use connection() or sl...
bool isSuspended() const
Flow control.
KURL::List srcURLs() const
Returns the list of source URLs.
TQByteArray data() const
Get hold of the downloaded data.
The transfer job pumps data into and/or out of a Slave.
The FileCopyJob copies data from one place to another.
A MimetypeJob is a TransferJob that allows you to get the mime type of an URL.
const KURL & redirectionURL() const
Returns the ListJob's redirection URL.
KURL::List urls() const
Returns the list of URLs.