-
Notifications
You must be signed in to change notification settings - Fork 6
/
SeedManager.cc
63 lines (50 loc) · 1.95 KB
/
SeedManager.cc
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
#include <QMetaMethod>
#include <QMetaObject>
#include "SeedManager.hpp"
#include "SeedManager_p.hpp"
static QMetaMethod getMethod(QObject *object, const char *function) {
auto metaObject = object->metaObject();
return metaObject->method(metaObject->indexOfMethod(QMetaObject::normalizedSignature(function)));
}
SeedManager::SeedManager(QObject *parent)
: QObject(parent) {
m_Private = QSharedPointer<SeedManagerPrivate>(new SeedManagerPrivate);
auto obj = m_Private.data();
connect(obj, &SeedManagerPrivate::errorSeeding,
this, &SeedManager::errorSeeding,
Qt::DirectConnection);
connect(obj, &SeedManagerPrivate::queuedSeeding,
this, &SeedManager::queuedSeeding,
Qt::DirectConnection);
connect(obj, &SeedManagerPrivate::startedSeeding,
this, &SeedManager::startedSeeding,
Qt::DirectConnection);
connect(obj, &SeedManagerPrivate::removingSeeding,
this, &SeedManager::removingSeeding,
Qt::DirectConnection);
connect(obj, &SeedManagerPrivate::stoppedSeeding,
this, &SeedManager::stoppedSeeding,
Qt::DirectConnection);
connect(obj, &SeedManagerPrivate::torrentStatus,
this, &SeedManager::torrentStatus,
Qt::DirectConnection);
}
void SeedManager::updateProxy() {
getMethod(m_Private.data(), "updateProxy(void)")
.invoke(m_Private.data(),
Qt::QueuedConnection);
}
void SeedManager::startSeeding(QString hash, QString path, QUrl torrentFileUrl) {
getMethod(m_Private.data(), "startSeeding(QString, QString, QUrl)")
.invoke(m_Private.data(),
Qt::QueuedConnection,
Q_ARG(QString, hash),
Q_ARG(QString, path),
Q_ARG(QUrl, torrentFileUrl));
}
void SeedManager::stopSeeding(QString hash) {
getMethod(m_Private.data(), "stopSeeding(QString)")
.invoke(m_Private.data(),
Qt::QueuedConnection,
Q_ARG(QString, hash));
}