21 #ifndef __tdeio_jobclasses_h__
22 #define __tdeio_jobclasses_h__
25 #include <tqptrlist.h>
27 #include <tqstringlist.h>
28 #include <tqguardedptr.h>
30 #include <sys/types.h>
34 #include <tdeio/global.h>
39 #define TDEIO_COPYJOB_HAS_SETINTERACTIVE // new in 3.4. Used by tdeio_trash.
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);
344 void infoMessage(
TDEIO::Job *job,
const TQString & msg );
353 void warning(
TDEIO::Job *job,
const TQString & msg );
372 void percent(
TDEIO::Job *job,
unsigned long percent );
395 void speed(
TDEIO::Job *job,
unsigned long speed );
414 void slotSpeed(
TDEIO::Job *job,
unsigned long speed );
421 void slotInfoMessage(
TDEIO::Job *job,
const TQString &msg );
426 void slotSpeedTimeout();
438 virtual void addSubjob(
Job *job,
bool inheritMetaData=
true );
448 virtual void removeSubjob(
Job *job );
457 void removeSubjob(
Job *job,
bool mergeMetaData,
bool emitResultIfLast );
475 void emitSpeed(
unsigned long speed );
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;
512 MetaData m_outgoingMetaData;
513 MetaData m_incomingMetaData;
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 );
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 );
744 void redirection(
TDEIO::Job *job,
const KURL &url );
754 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
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 );
809 void redirection(
TDEIO::Job *job,
const KURL &url );
818 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
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();
976 void data(
TDEIO::Job *job,
const TQByteArray &data );
989 void dataReq(
TDEIO::Job *job, TQByteArray &data );
998 void redirection(
TDEIO::Job *job,
const KURL &url );
1008 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
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 );
1130 MultiGetJob(
const KURL& url,
bool showProgressInfo);
1138 virtual void start(
Slave *slave);
1147 void get(
long id,
const KURL &url,
const MetaData &metaData);
1156 void data(
long id,
const TQByteArray &data);
1163 void mimetype(
long id,
const TQString &type );
1172 void result(
long id);
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)
1183 : id(_id), url(_url), 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);
1283 void setModificationTime( time_t mtime );
1288 void setSourceSize( off_t size ) KDE_DEPRECATED;
1316 void slotData(
TDEIO::Job *,
const TQByteArray &data);
1317 void slotDataReq(
TDEIO::Job *, TQByteArray &data);
1318 void slotMimetype(
TDEIO::Job *,
const TQString& type );
1344 void slotPercent(
TDEIO::Job *job,
unsigned long pct );
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);
1441 void entries(
TDEIO::Job *job,
const TDEIO::UDSEntryList& list);
1450 void redirection(
TDEIO::Job *job,
const KURL &url );
1460 void permanentRedirection(
TDEIO::Job *job,
const KURL &fromUrl,
const KURL &toUrl );
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 );
1581 void totalFiles(
TDEIO::Job *job,
unsigned long files );
1587 void totalDirs(
TDEIO::Job *job,
unsigned long dirs );
1596 void aboutToCreate(
TDEIO::Job *job,
const TQValueList<TDEIO::CopyInfo> &files);
1603 void processedFiles(
TDEIO::Job *job,
unsigned long files );
1609 void processedDirs(
TDEIO::Job *job,
unsigned long dirs );
1618 void copying(
TDEIO::Job *job,
const KURL& from,
const KURL& to );
1626 void linking(
TDEIO::Job *job,
const TQString& target,
const KURL& to );
1634 void moving(
TDEIO::Job *job,
const KURL& from,
const KURL& to );
1640 void creatingDir(
TDEIO::Job *job,
const KURL& dir );
1647 void renamed(
TDEIO::Job *job,
const KURL& from,
const KURL& to );
1661 void copyingDone(
TDEIO::Job *job,
const KURL &from,
const KURL &to,
bool directory,
bool renamed );
1671 void copyingLinkDone(
TDEIO::Job *job,
const KURL &from,
const TQString& target,
const KURL& to );
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; }
1790 void totalFiles(
TDEIO::Job *job,
unsigned long files );
1796 void totalDirs(
TDEIO::Job *job,
unsigned long dirs );
1803 void processedFiles(
TDEIO::Job *job,
unsigned long files );
1809 void processedDirs(
TDEIO::Job *job,
unsigned long dirs );
1817 void deleting(
TDEIO::Job *job,
const KURL& file );
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;
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.