22 #ifndef __kio_jobclasses_h__
23 #define __kio_jobclasses_h__
26 #include <tqptrlist.h>
28 #include <tqstringlist.h>
29 #include <tqguardedptr.h>
31 #include <sys/types.h>
35 #include <kio/global.h>
40 #define KIO_COPYJOB_HAS_SETINTERACTIVE
68 class KIO_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);
407 virtual void slotResult(
KIO::Job *job );
415 void slotSpeed(
KIO::Job *job,
unsigned long speed );
422 void slotInfoMessage(
KIO::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 );
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 );
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 KIO_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);
905 virtual void slotResult(
KIO::Job *job );
940 void setAsyncDataEnabled(
bool enabled);
948 void sendAsyncData(
const TQByteArray &data);
957 void setReportDataSent(
bool enabled);
965 bool reportDataSent();
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(
KIO::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(
KIO::Job *job,
const TQByteArray &data );
1108 void slotStoredDataReq(
KIO::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);
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(
KIO::Job *,
const TQByteArray &data);
1318 void slotDataReq(
KIO::Job *, TQByteArray &data);
1319 void slotMimetype(
KIO::Job *,
const TQString& type );
1326 virtual void slotResult(
KIO::Job *job );
1345 void slotPercent(
KIO::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);
1464 virtual void slotFinished( );
1466 virtual void slotResult(
KIO::Job *job );
1467 void slotListEntries(
const KIO::UDSEntryList& list );
1468 void slotRedirection(
const KURL &url );
1469 void gotEntries(
KIO::Job * subjob,
const KIO::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 KIO_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 );
1675 void statCurrentSrc();
1679 void slotResultStating(
KIO::Job * job );
1680 void startListing(
const KURL & src );
1681 void slotResultCreatingDirs(
KIO::Job * job );
1682 void slotResultConflictCreatingDirs(
KIO::Job * job );
1683 void createNextDir();
1684 void slotResultCopyingFiles(
KIO::Job * job );
1685 void slotResultConflictCopyingFiles(
KIO::Job * job );
1686 void copyNextFile();
1687 void slotResultDeletingDirs(
KIO::Job * job );
1688 void deleteNextDir();
1689 void skip(
const KURL & sourceURL );
1690 void slotResultRenaming(
KIO::Job * job );
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(
KIO::Job*,
const KIO::UDSEntryList& list );
1702 virtual void slotResult(
KIO::Job *job );
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; }
1822 void slotEntries(
KIO::Job*,
const KIO::UDSEntryList& list );
1823 virtual void slotResult(
KIO::Job *job );
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;
CopyJob is used to move, copy or symlink files and directories.
KURL::List srcURLs() const
Returns the list of source URLs.
CopyMode
Defines the mode of the operation.
void moving(KIO::Job *job, const KURL &from, const KURL &to)
void copyingLinkDone(KIO::Job *job, const KURL &from, const TQString &target, const KURL &to)
void totalFiles(KIO::Job *job, unsigned long files)
Emitted when the total number of files is known.
void aboutToCreate(KIO::Job *job, const TQValueList< KIO::CopyInfo > &files)
Emitted when it is known which files / directories are going to be created.
void totalDirs(KIO::Job *job, unsigned long dirs)
Emitted when the toal number of direcotries is known.
void renamed(KIO::Job *job, const KURL &from, const KURL &to)
void creatingDir(KIO::Job *job, const KURL &dir)
void linking(KIO::Job *job, const TQString &target, const KURL &to)
void processedDirs(KIO::Job *job, unsigned long dirs)
Sends the number of processed directories.
void processedFiles(KIO::Job *job, unsigned long files)
Sends the number of processed files.
KURL destURL() const
Returns the destination URL.
void copying(KIO::Job *job, const KURL &from, const KURL &to)
void copyingDone(KIO::Job *job, const KURL &from, const KURL &to, bool directory, bool renamed)
A more complex Job to delete files and directories.
void totalFiles(KIO::Job *job, unsigned long files)
Emitted when the total number of files is known.
void processedFiles(KIO::Job *job, unsigned long files)
Sends the number of processed files.
void processedDirs(KIO::Job *job, unsigned long dirs)
Sends the number of processed directories.
void totalDirs(KIO::Job *job, unsigned long dirs)
Emitted when the toal number of direcotries is known.
void deleting(KIO::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.
The FileCopyJob copies data from one place to another.
KURL destURL() const
Returns the destination URL.
KURL srcURL() const
Returns the source URL.
void mimetype(KIO::Job *job, const TQString &type)
Mimetype determined during a file copy.
The base class for all jobs.
void infoMessage(KIO::Job *job, const TQString &msg)
void connected(KIO::Job *job)
void warning(KIO::Job *job, const TQString &msg)
Emitted to display a warning about this job, as sent by the slave.
void processedSize(KIO::Job *job, KIO::filesize_t size)
int error() const
Returns the error code, if there has been an error.
void percent(KIO::Job *job, unsigned long percent)
void canceled(KIO::Job *job)
void result(KIO::Job *job)
void totalSize(KIO::Job *job, KIO::filesize_t size)
void speed(KIO::Job *job, unsigned long speed)
const TQString & errorText() const
Returns the error text if there has been an error.
int progressId() const
Returns the progress id for this job.
A ListJob is allows you to get the get the content of a directory.
void entries(KIO::Job *job, const KIO::UDSEntryList &list)
void permanentRedirection(KIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
void redirection(KIO::Job *job, const KURL &url)
const KURL & redirectionURL() const
Returns the ListJob's redirection URL.
A MimetypeJob is a TransferJob that allows you to get the mime type of an URL.
TQString mimetype() const
A KIO job that creates a directory.
void redirection(KIO::Job *job, const KURL &url)
void permanentRedirection(KIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
The MultiGetJob is a TransferJob that allows you to get several files from a single server.
void mimetype(long id, const TQString &type)
void data(long id, const TQByteArray &data)
A simple job (one url and one command).
const KURL & url() const
Returns the SimpleJob's URL.
Attention developers: If you change the implementation of KIO::Slave, do not use connection() or slav...
A KIO job that retrieves information about a file or directory.
void setDetails(short int details)
void redirection(KIO::Job *job, const KURL &url)
void setSide(bool source)
A stat() can have two meanings.
const UDSEntry & statResult() const
void permanentRedirection(KIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
StoredTransferJob is a TransferJob (for downloading or uploading data) that also stores a TQByteArray...
TQByteArray data() const
Get hold of the downloaded data.
The transfer job pumps data into and/or out of a Slave.
void mimetype(KIO::Job *job, const TQString &type)
void redirection(KIO::Job *job, const KURL &url)
void data(KIO::Job *job, const TQByteArray &data)
Data from the slave has arrived.
bool isErrorPage() const
Checks whether we got an error page.
void dataReq(KIO::Job *job, TQByteArray &data)
void permanentRedirection(KIO::Job *job, const KURL &fromUrl, const KURL &toUrl)
Observer for KIO::Job progress information.
A namespace for KIO globals.
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
KIO_EXPORT TransferJob * get(const KURL &url, bool reload=false, bool showProgressInfo=true)
Get (a.k.a.
TQ_ULLONG filesize_t
64-bit file size
KIO_EXPORT MimetypeJob * mimetype(const KURL &url, bool showProgressInfo=true)
Find mimetype for one file or directory.
KIO_EXPORT CopyJob * move(const KURL &src, const KURL &dest, bool showProgressInfo=true)
Moves a file or directory src to the given destination dest.