1
/***************************************************************************
2
* Copyright © 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com> *
4
* This program is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU General Public License as *
6
* published by the Free Software Foundation; either version 2 of *
7
* the License or (at your option) version 3 or any later version *
8
* accepted by the membership of KDE e.V. (or its successor approved *
9
* by the membership of KDE e.V.), which shall act as a proxy *
10
* defined in Section 14 of version 3 of the license. *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
19
***************************************************************************/
21
#include "ApplicationUpdates.h"
22
#include "BackendsSingleton.h"
23
#include <Application.h>
24
#include <ApplicationBackend.h>
25
#include "MuonInstallerMainWindow.h"
26
#include <LibQApt/Backend>
29
ApplicationUpdates::ApplicationUpdates(QObject* parent): QObject(parent)
31
QApt::Backend* backend = BackendsSingleton::self()->backend();
32
connect(backend, SIGNAL(errorOccurred(QApt::ErrorCode,QVariantMap)), this,
33
SLOT(errorOccurred(QApt::ErrorCode,QVariantMap)));
34
connect(backend, SIGNAL(commitProgress(QString,int)),
35
SIGNAL(progress(QString,int)));
36
connect(backend, SIGNAL(downloadMessage(int,QString)), SIGNAL(downloadMessage(int,QString)));
37
connect(backend, SIGNAL(debInstallMessage(QString)), SIGNAL(installMessage(QString)));
38
connect(backend, SIGNAL(workerEvent(QApt::WorkerEvent)),
39
this, SLOT(workerEvent(QApt::WorkerEvent)));
42
void ApplicationUpdates::upgradeAll()
44
QApt::Backend* backend = BackendsSingleton::self()->backend();
45
QApt::PackageList packages = backend->upgradeablePackages();
46
foreach(QApt::Package* p, packages) {
49
backend->commitChanges();
52
void ApplicationUpdates::workerEvent(QApt::WorkerEvent e)
54
if(e==QApt::CommitChangesFinished) {
55
qDebug() << "updates done. Reloading...";
57
//when it's done, trigger a reload of the whole system
58
BackendsSingleton::self()->applicationBackend()->reload();
59
emit updatesFinnished();
63
void ApplicationUpdates::errorOccurred(QApt::ErrorCode e, const QVariantMap&)
67
emit updatesFinnished();
68
BackendsSingleton::self()->backend()->undo();