summaryrefslogtreecommitdiff
path: root/lib/Transaction.h
blob: b6a49b6f61cf5c4742fb52fd2b88e32ba2e796b5 (plain)
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
/*
* Copyright (C) 2007 Adrien Bustany <madcat@mymadcat.com>
*
* Licensed under the GNU General Public License Version 2
*
* 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 See MA 02111-1307, USA.
*
*/

#ifndef TRANSACTION_H
#define TRANSACTION_H

#include <QtCore>

#include "TransactionProxy.h"
#include "Package.h"
#include "Provides.h"
#include "SignatureType.h"

// Enums
#include "Exit.h"
#include "Role.h"
#include "Status.h"
#include "Error.h"
#include "Groups.h"

namespace PackageKit {

class Daemon;
class PolkitClient;

class Transaction : public QObject {

	Q_OBJECT

public:
	Transaction(Daemon *parent = 0);
	~Transaction();

	// PackageKit functions
	bool allowCancel();
	void cancel();
	Role::Value getRole(Package *p = NULL);
	Status::Value getStatus();

	void searchName(const QString& filter, const QString& name);
	void searchDetails(const QString &filter, const QString& search);
	void searchGroup(const QString &filter, const Groups::Value &group);
	void searchFile(const QString &filter, const QString& file);
	void getPackages(const QString& filter);
	void getDetails(Package *p);
	void getFiles(Package *p);
	void getDepends(const QString &filter, Package *p, bool recursive = true);
	void getRequires( const QString &filter, Package *p, bool recursive = true);
	void whatProvides(const QString &filter, const Provides::Value &type, const QString& search);
	void resolve(const QString &filter, Package *p);

	void installPackages(const QList<Package*> &packages);
	void installPackage(Package *p);
	void installSignature(const SignatureType::Value &type, const QString &key_id, Package *p);
	void updatePackages(const QList<Package*> &packages);
	void updatePackage(Package *p);
	void installFiles(const QStringList& files, bool trusted = false);
	void removePackages(const QList<Package*> &packages, bool allow_deps = false, bool autoremove = false);
	void removePackage(Package *p, bool allow_deps = false, bool autoremove = false);

	void updateSystem();
	void rollback(const QString &tid);

	void getUpdates(const QString& filter);
	void getUpdateDetail(const QString& package_id);

	void refreshCache(bool force = false);
	void getProgress(uint &percentage, uint &subpercentage, uint &elapsed, uint &remaining);
	void getRepoList(const QString &filter);
	void repoEnable(const QString &repo_id, bool enabled);
	void repoSetData(const QString &repo_id, const QString &parameter, const QString &value);
	bool isCallerActive();
	void getOldTransactions(uint number);
	void acceptEula(const QString &id);

signals:
	void GotPackage(Package *p);
	void Details(Package *p, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size);
	void Files(Package *p, QStringList files);
	void Finished(Exit::Value status, uint runtime);
	void ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining);
	void UpdateDetail(const QString &package_id, const QString &updates, const QString &obsoletes, const QString &vendor_url, const QString &bugzilla_url, const QString &cve_url, const QString &restart, const QString &update_text);
	void RequireRestart(const QString&, const QString&);
	void AllowCancel(bool allow_cancel);
    void ErrorCode(Error::Value, const QString &details);
    void Message(const QString &message, const QString &details);
	void StatusChanged(Status::Value v);
	void RepoDetail(const QString &repo_id, const QString &details, bool enabled);
	void OldTransaction(const QString &tid, const QString &timespec, bool succeeded, Role::Value role, uint duration, const QString& data);
	void EulaRequired(const QString &id, Package *p, const QString &vendor_name, const QString &agreement);
	void RepoSignatureRequired(Package *p, const QString &repository_name, const QString &key_url, const QString &key_userid, const QString &key_id, const QString &key_fingerprint, const QString &key_timestamp, SignatureType::Value type);
	void CallerActiveChanged(bool active);

private slots:
	void Package_cb(const QString &info, const QString &package_id, const QString &summary);
	void Details_cb(const QString &package_id, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size);
	void Files_cb(const QString &pid, const QString &file_list);
	void Finished_cb(const QString& exit, uint runtime);
	void ErrorCode_cb(const QString &code, const QString &details);
	void StatusChanged_cb(const QString& status);
	void Transaction_cb(const QString &tid, const QString &timespec, bool succeeded, const QString &role, uint duration, const QString& data);
	void EulaRequired_cb(const QString &id, const QString &package_id, const QString &vendor_name, const QString &agreement);
	void RepoSignatureRequired_cb(const QString &package_id, const QString &repository_name, const QString &key_url, const QString &key_userid, const QString &key_id, const QString &key_fingerprint, const QString &key_timestamp, const QString &type);

private:
	TransactionProxy *proxy;
	Daemon *parent;
	QString _tid;
	// Get a new TID if needed
	void renewTid();

	PolkitClient *polkit;

};

} // End namespace PackageKit

#endif