kget
bttransfer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef BTTRANSFER_H
00012 #define BTTRANSFER_H
00013
00014 #include <QTimer>
00015
00016 #include "core/transfer.h"
00017 #include "torrent/torrentcontrol.h"
00018
00019 class BTTransfer : public QObject, public Transfer
00020 {
00021 Q_OBJECT
00022
00023 public:
00027 enum BTTransferChange
00028 {
00029 Tc_ChunksTotal = 0x00010000,
00030 Tc_ChunksDownloaded = 0x00020000,
00031 Tc_ChunksExcluded = 0x00040000,
00032 Tc_ChunksLeft = 0x00080000,
00033 Tc_SeedsConnected = 0x00160000,
00034 Tc_SeedsDisconnected = 0x00320000,
00035 Tc_LeechesConnected = 0x00640000,
00036 Tc_LeechesDisconnected = 0x01280000,
00037 Tc_DlRate = 0x02560000,
00038 Tc_UlRate = 0x05120000,
00039 Tc_UlLimit = 0x07860000,
00040 Tc_DlLimit = 0x09840000,
00041 Tc_SessionBytesDownloaded = 0x10240000,
00042 Tc_SessionBytesUploaded = 0x20480000,
00043 Tc_TrackersList = 0x40960000
00044 };
00045
00046 BTTransfer(TransferGroup* parent, TransferFactory* factory,
00047 Scheduler* scheduler, const KUrl& src, const KUrl& dest,
00048 const QDomElement * e = 0);
00049 ~BTTransfer();
00050
00051
00052 void start();
00053 void stop();
00054 int elapsedTime() const;
00055 int remainingTime() const;
00056 bool isResumable() const;
00057
00058
00059 int chunksTotal() const;
00060 int chunksDownloaded() const;
00061 int chunksExcluded() const;
00062 int chunksLeft() const;
00063 int seedsConnected() const;
00064 int seedsDisconnected() const;
00065 int leechesConnected() const;
00066 int leechesDisconnected() const;
00067 int dlRate() const;
00068 int ulRate() const;
00069 float totalSize() const;
00070 float processedSize() const;
00071 int sessionBytesDownloaded() const;
00072 int sessionBytesUploaded() const;
00073 KUrl::List trackersList() const;
00074 bt::TorrentControl * torrentControl();
00075 int ulLimit() const;
00076 int dlLimit() const;
00077 int percent() const;
00078
00079
00080 void setPort(int port);
00081 void setTrafficLimits(int ulLimit, int dlLimit);
00082 void setMaxShareRatio(float ratio);
00083 void addTracker(QString url);
00084 void save(const QDomElement &element);
00085
00086 bool ready();
00087
00088 protected:
00089 void load(const QDomElement &e);
00090
00091 private slots:
00092 void init(KUrl src = KUrl());
00093 void update();
00094 void slotStoppedByError(bt::TorrentInterface* error, QString errormsg);
00095 void slotDownloadFinished(bt::TorrentInterface* ti);
00096
00097 private:
00098 void startTorrent();
00099 void stopTorrent();
00100 void updateTorrent();
00101
00102 bt::TorrentControl *torrent;
00103 QString m_tmp;
00104 int m_dlLimit;
00105 int m_ulLimit;
00106 float m_ratio;
00107 QTimer timer;
00108 bool m_ready;
00109 bool m_downloadFinished;
00110 };
00111
00112 #endif