downloader.h
00001 #ifndef _DOWNLOADER_H
00002 #define _DOWNLOADER_H
00003
00004 #include <kurl.h>
00005 #include <qobject.h>
00006 #include <qptrlist.h>
00007
00008 class QFile;
00009 class QTimer;
00010 class Downloader;
00011
00012
00013 namespace KIO
00014 {
00015 class TransferJob;
00016 class Job;
00017 }
00018
00022 class DownloadItem
00023 {
00024 friend class Downloader;
00025 public:
00026 DownloadItem();
00027 virtual ~DownloadItem();
00028
00029 bool isDownloaded() const;
00030
00034 QString localFilename() const;
00035
00036 virtual void setLocalFilename(const QString &filename);
00037
00041 virtual void downloadFinished();
00045 virtual void downloaded(int percent);
00049 virtual void downloadTimeout();
00053 bool enqueue(const KURL &url);
00057 void dequeue();
00058
00059 private:
00060 QString mLocalFilename;
00061 };
00062
00066 class Downloader : public QObject
00067 {
00068 Q_OBJECT
00069 struct QueueItem
00070 {
00071 DownloadItem *notifier;
00072 KURL file;
00073 QString local;
00074 };
00075
00076 public:
00077 Downloader(QObject *parent=0);
00078 virtual ~Downloader();
00079
00080 public slots:
00081 QString enqueue(DownloadItem *notifier, const KURL &file);
00082 void dequeue(DownloadItem *notifier);
00083
00087 void start();
00088
00089 signals:
00094 void enqueued(DownloadItem *notifier, const KURL &file);
00099 void dequeued(DownloadItem *notifier);
00100
00101 private slots:
00102 void getNext();
00103
00104 void data( KIO::Job *, const QByteArray &data);
00105 void percent( KIO::Job *, unsigned long percent);
00106 void jobDone( KIO::Job *);
00107 void giveUpWithThisDownloadServerIsRunningNT();
00108
00109 private:
00110 QPtrList<Downloader::QueueItem> mQueue;
00111 QPtrList<Downloader::QueueItem> *mUnstartedQueue;
00112 QFile *localfile;
00113 Downloader::QueueItem *current;
00114 KIO::TransferJob *mJob;
00115 QTimer *mTimeout;
00116 bool mStarted;
00117 };
00118
00119 #endif
00120
This file is part of the documentation for Noatun 2.6.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 23:49:45 2004 by
doxygen 1.3.8-20040913 written by
Dimitri van Heesch, © 1997-2003