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
|
#include "Transaction.h"
#include "constants.h"
using namespace PackageKit;
Transaction::Transaction(QString tid, QObject *parent) : QObject(parent) {
_tid = tid;
proxy = new TransactionProxy(PK_NAME, (tid).toAscii().data() , QDBusConnection::systemBus(), this);
qDebug() << "trying to create new transaction with path" << (tid).toAscii().data();
if(!proxy->isValid()) qFatal("Error, cannot create transaction");
connect(proxy, SIGNAL(Package(const QString&, const QString&, const QString&)), this, SLOT(Package_cb(const QString&, const QString&, const QString&)));
connect(proxy, SIGNAL(Details(const QString&, const QString&, const QString&, const QString&, const QString&, qulonglong)), this, SLOT(Details_cb(const QString&, const QString&, const QString&, const QString&, const QString&, qulonglong)));
connect(proxy, SIGNAL(Finished(const QString&, uint)), this, SLOT(Finished_cb(const QString&, uint)));
connect(proxy, SIGNAL(ProgressChanged(uint, uint, uint, uint)), this, SIGNAL(ProgressChanged(uint, uint, uint, uint)));
}
Transaction::~Transaction() {
}
void Transaction::cancel() {
proxy->Cancel();
}
Role::Value Transaction::getRole(Package *p) {
QString pid;
Role::Value role = (Role::Value)EnumFromString<Role>(proxy->GetRole(pid));
if(p != NULL) p = new Package(pid);
return role;
}
Status::Value Transaction::getStatus() {
return (Status::Value)EnumFromString<Status>(proxy->GetStatus());
}
void Transaction::searchName(const QString& filter, const QString& name) {
qDebug() << "search for " << name;
proxy->SearchName(filter, name);
}
void Transaction::getDetails(Package *p) {
proxy->GetDetails(p->id());
}
// Signal callbacks
void Transaction::Package_cb(const QString &info, const QString &package_id, const QString &summary) {
emit GotPackage(new Package(package_id, info, summary, this));
}
void Transaction::Details_cb(const QString &package_id, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size) {
emit Details(new Package(package_id), license, group, detail, url, size);
}
void Transaction::Finished_cb(const QString& exit, uint runtime) {
emit Finished((Exit::Value)EnumFromString<Exit>(exit), runtime);
}
|