* fix a lot of compiler warnings
[kdenetwork.git] / kget / transfer-plugins / bittorrent / bttransfer.h
blob322b4952f4b4e1edc00ccf2ea1d23f4070590e90
1 /* This file is part of the KDE project
3 Copyright (C) 2007 Lukas Appelhans <l.appelhans@gmx.de>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9 */
11 #ifndef BTTRANSFER_H
12 #define BTTRANSFER_H
14 #include <QTimer>
16 #include "core/transfer.h"
17 #include "torrent/torrentcontrol.h"
19 class BTTransfer : public QObject, public Transfer
21 Q_OBJECT
23 public:
24 /**
25 * Here we define the Bittorrent specific flags.
27 enum BTTransferChange
29 Tc_ChunksTotal = 0x00010000,
30 Tc_ChunksDownloaded = 0x00020000,
31 Tc_ChunksExcluded = 0x00040000,
32 Tc_ChunksLeft = 0x00080000,
33 Tc_SeedsConnected = 0x00160000,
34 Tc_SeedsDisconnected = 0x00320000,
35 Tc_LeechesConnected = 0x00640000,
36 Tc_LeechesDisconnected = 0x01280000,
37 Tc_DlRate = 0x02560000,
38 Tc_UlRate = 0x05120000,
39 Tc_UlLimit = 0x07860000,
40 Tc_DlLimit = 0x09840000,
41 Tc_SessionBytesDownloaded = 0x10240000,
42 Tc_SessionBytesUploaded = 0x20480000,
43 Tc_TrackersList = 0x40960000
46 BTTransfer(TransferGroup* parent, TransferFactory* factory,
47 Scheduler* scheduler, const KUrl& src, const KUrl& dest,
48 const QDomElement * e = 0);
49 ~BTTransfer();
51 //Job virtual functions
52 void start();
53 void stop();
54 int elapsedTime() const;
55 int remainingTime() const;
56 bool isResumable() const;
58 //Bittorrent specific functions (connected with TransferFlags
59 int chunksTotal() const;
60 int chunksDownloaded() const;
61 int chunksExcluded() const;
62 int chunksLeft() const;
63 int seedsConnected() const;
64 int seedsDisconnected() const;
65 int leechesConnected() const;
66 int leechesDisconnected() const;
67 int dlRate() const;
68 int ulRate() const;
69 int totalSize() const;
70 int sessionBytesDownloaded() const;
71 int sessionBytesUploaded() const;
72 KUrl::List trackersList() const;
73 bt::TorrentControl * torrentControl();
74 int ulLimit() const;
75 int dlLimit() const;
76 int percent() const;
78 //More Bittorrent-Functions
79 void setPort(int port);
80 void setTrafficLimits(int ulLimit, int dlLimit);
81 void addTracker(QString url);
82 void save(const QDomElement &element);
84 bool ready();
86 protected:
87 void load(const QDomElement &e);
89 private slots:
90 void init(KUrl src = KUrl());
91 void update();
92 void slotStoppedByError(bt::TorrentInterface* error, QString errormsg);
93 void slotDownloadFinished(bt::TorrentInterface* ti);
95 private:
96 bt::TorrentControl *torrent;
98 QString m_tmp;
99 int m_dlLimit;
100 int m_ulLimit;
101 QTimer timer;
102 bool m_ready;
105 #endif