KVIrc  4.9.2
DeveloperAPIs
KTorrentDbusInterface.h
Go to the documentation of this file.
1 #ifndef _TC_KTORRENTDCOPINTERFACE_H_
2 #define _TC_KTORRENTDCOPINTERFACE_H_
3 
4 //=============================================================================
5 //
6 // DBus interface for KTorrent client.
7 //
8 // File : KTorrentDbusInterface.h
9 // Creation date : Mon Nov 17 13:46:00 2008 GMT by Fabio Bas
10 //
11 // This file is part of the KVIrc IRC client distribution
12 // Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com)
13 //
14 // This program is FREE software. You can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the HOPE that it will be USEFUL,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 // See the GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program. If not, write to the Free Software Foundation,
26 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 //
28 //=============================================================================
29 
30 #include "TorrentInterface.h"
31 
32 #ifdef COMPILE_KDE_SUPPORT
33 
34 #include <QtDBus/QtDBus>
35 
36 class KTorrentDbusInterface : public TorrentInterface
37 {
38  Q_OBJECT
39 
40 public:
41  KTorrentDbusInterface();
42  virtual ~KTorrentDbusInterface();
43 
44  virtual int detect();
45 
46  virtual bool startAll();
47  virtual bool stopAll();
48 
49  virtual int count();
50  virtual bool start(int i);
51  virtual bool stop(int i);
52  virtual bool announce(int i);
53  virtual QString state(int i);
54  virtual QString name(int i);
55  virtual int fileCount(int i);
56  virtual QString fileName(int i, int file);
57  virtual QString filePriority(int i, int file);
58  virtual bool setFilePriority(int i, int file, const QString & prio);
59 
60  virtual int maxUploadSpeed();
61  virtual int maxDownloadSpeed();
62 
63  virtual bool setMaxUploadSpeed(int kbytes_per_sec);
64  virtual bool setMaxDownloadSpeed(int kbytes_per_sec);
65 
66  virtual float speedUp();
67  virtual float speedDown();
68 
69  virtual float trafficUp();
70  virtual float trafficDown();
71  /*
72  private slots:
73  // polls client and extracts information.
74  // this is done because the order of torrents returned changes
75  // each time a torrent's state changes.
76  // we want to present a consistent list (in terms of indices) to
77  // the user, so we extract the info and sort it by name.
78  // otherwise the user would have a hard time figuring out what's
79  // going on. we could sort each time a function working with
80  // torrents is called, but this would be horribly slow ...
81  void slotTimer();
82  private:
83  struct TorrentInfo
84  {
85  // internal number
86  int num;
87  // name displayed in ktorrent
88  QString name;
89  // state of torrent
90  QString state;
91  // bytes
92  float size;
93  // bytes
94  float trafficUp;
95  // bytes
96  float trafficDown;
97  // KB/s
98  float speedUp;
99  // KB/s
100  float speedDown;
101  // percent complete
102  float percent;
103  // number of peers
104  int peers;
105  bool operator<(const TorrentInfo &ti) { return name < ti.name; }
106  };
107 
108  QValueList<TorrentInfo> m_ti;
109 */
110 private:
111  // bool makeTorrentInfo(TorrentInfo &ti, const KviQCStringList &ret);
112  bool findRunningApp();
113 };
114 
115 TORR_DECLARE_DESCRIPTOR(KTorrentDbusInterface)
116 
117 #endif // COMPILE_KDE_SUPPORT
118 
119 #endif // _TC_KTORRENTDCOPINTERFACE_H_
virtual int maxDownloadSpeed()=0
#define TORR_DECLARE_DESCRIPTOR(_interfaceclass)
Definition: TorrentInterface.h:118
virtual bool stop(int i)=0
virtual bool start(int i)=0
virtual float trafficDown()=0
#define i
Definition: detector.cpp:73
virtual QString filePriority(int i, int file)=0
virtual int maxUploadSpeed()=0
virtual QString state(int i)=0
virtual bool startAll()=0
virtual bool announce(int i)=0
virtual float speedUp()=0
virtual bool setMaxDownloadSpeed(int kbytes_per_sec)=0
virtual int count()=0
virtual bool stopAll()=0
virtual QString name(int i)=0
virtual bool setFilePriority(int i, int file, const QString &prio)=0
virtual int fileCount(int i)=0
Definition: TorrentInterface.h:35
virtual float trafficUp()=0
virtual int detect()=0
virtual QString fileName(int i, int file)=0
virtual float speedDown()=0
virtual bool setMaxUploadSpeed(int kbytes_per_sec)=0