1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#ifndef _TC_INTERFACE_H_
#define _TC_INTERFACE_H_
//=============================================================================
//
// Common interface for BitTorrent clients.
//
// File : tc_interface.h
// Creation date : Fri Jan 1 15:42:25 2007 GMT by Alexander Stillich
//
// This file is part of the KVirc irc client distribution
// Copyright (C) 2001-2005 Szymon Stefanek (pragma at kvirc dot net)
// Copyright (C) 2007 Alexander Stillich (torque at pltn dot org)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your opinion) any later version.
//
// This program is distributed in the HOPE that it will be USEFUL,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, write to the Free Software Foundation,
// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================
#include "kvi_settings.h"
#include "kvi_qstring.h"
#include <qobject.h>
class KviTorrentInterface : public QObject
{
public:
KviTorrentInterface() {}
virtual ~KviTorrentInterface() {}
virtual int detect() = 0;
// returns number of torrents in client
virtual int count()=0;
/*
// path of torrent file
virtual QCString getTorrentFile(int i)=0;
// directory where data is downloaded to
virtual QCString getTorrentDataDir(int i)=0;
*/
// number of files in torrent
virtual int fileCount(int i)=0;
// name of file in torrent
virtual QString fileName(int i, int file)=0;
// returns file priority (low, normal, high)
virtual QString filePriority(int i, int file)=0;
// sets file priority
virtual bool setFilePriority(int i, int file, const QString &prio)=0;
virtual bool start(int i)=0;
virtual bool stop(int i)=0;
virtual bool announce(int i)=0;
virtual bool startAll()=0;
virtual bool stopAll()=0;
/*
// remove torrent from client
virtual bool removeTorrent(int i)=0;
virtual bool addTorrent(const QCString &mrl);
*/
// returns state of torrent number i (Stopped, Stalled, Seeding, Downloading)
// this uses getTorrentInfo() to obtain the state and then
// returns it as string
virtual QString state(int i)=0;
// name of torrent as displayed in client
// uses getTorrentInfo()
virtual QString name(int i)=0;
virtual float speedUp()=0;
virtual float speedDown()=0;
virtual float trafficUp()=0;
virtual float trafficDown()=0;
virtual int maxUploadSpeed()=0;
virtual int maxDownloadSpeed()=0;
virtual bool setMaxUploadSpeed(int kbytes_per_sec)=0;
virtual bool setMaxDownloadSpeed(int kbytes_per_sec)=0;
QString lastError() { return m_lastError; }
static void select(KviTorrentInterface *i) { m_selected = i; }
static KviTorrentInterface *selected() { return m_selected; }
protected:
QString m_lastError;
static KviTorrentInterface *m_selected;
};
class KviTorrentInterfaceDescriptor
{
public:
KviTorrentInterfaceDescriptor() {};
virtual ~KviTorrentInterfaceDescriptor() {};
public:
virtual const QString & name() = 0;
virtual const QString & description() = 0;
virtual KviTorrentInterface * instance() = 0;
};
#define TORR_DECLARE_DESCRIPTOR(_interfaceclass) \
class _interfaceclass ## Descriptor : public KviTorrentInterfaceDescriptor \
{ \
public: \
_interfaceclass ## Descriptor(); \
virtual ~_interfaceclass ## Descriptor(); \
protected: \
_interfaceclass * m_pInstance; \
QString m_szName; \
QString m_szDescription; \
public: \
virtual const QString & name(); \
virtual const QString & description(); \
virtual KviTorrentInterface * instance(); \
};
#define TORR_IMPLEMENT_DESCRIPTOR(_interfaceclass,_name,_description) \
_interfaceclass ## Descriptor::_interfaceclass ## Descriptor() \
: KviTorrentInterfaceDescriptor() \
{ \
m_pInstance = 0; \
m_szName = _name; \
m_szDescription = _description; \
} \
_interfaceclass ## Descriptor::~_interfaceclass ## Descriptor() \
{ \
delete m_pInstance; \
} \
const QString & _interfaceclass ## Descriptor::name() \
{ \
return m_szName; \
} \
const QString & _interfaceclass ## Descriptor::description() \
{ \
return m_szDescription; \
} \
KviTorrentInterface * _interfaceclass ## Descriptor::instance() \
{ \
if (!m_pInstance) m_pInstance = new _interfaceclass(); \
return m_pInstance; \
}
#endif // _TC_INTERFACE_H_
|