upgradeoperation.cpp 1.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/* This file is part of the Chakra project

   Copyright (C) 2011 Lukas Appelhans

   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 option) any later version.
*/

#include "upgradeoperation.h"
12
#include "queueoperation.h"
13 14 15 16

#include <akabeiclientbackend.h>
#include <akabeiclientqueue.h>
#include <akabeiclienttransactionhandler.h>
17
#include <akabeioperationrunner.h>
18
#include <akabeiconfig.h>
19

20 21 22
#include <QFile>
#include <QDir>
#include <QCoreApplication>
Lukas Appelhans's avatar
Lukas Appelhans committed
23
#include <iostream>
24 25

UpgradeOperation::UpgradeOperation(QObject * parent)
26
  : QObject(parent)
27 28 29 30 31 32 33 34 35
{

}

UpgradeOperation::~UpgradeOperation()
{

}

36
void UpgradeOperation::start(QList<APM::OperationName> operations, QHash<APM::OptionName, QStringList> options, QStringList args)
37
{
38
    Akabei::Package::List pkgs;
Lukas Appelhans's avatar
Lukas Appelhans committed
39 40 41 42 43
    foreach (const QString &p, args) {
        Akabei::Package * pkg = Akabei::Backend::instance()->loadPackageFromFile(p);
        if (pkg)
            pkgs << pkg;
    }
44

Lukas Appelhans's avatar
Lukas Appelhans committed
45 46 47 48
    if (pkgs.isEmpty()) {
        emit upgradeFinished();
        return;
    }
49

50
    QueueOperation *op = new QueueOperation(operations.first(), options, this);
51
    op->start(AkabeiClient::Install, pkgs);
52
    connect(op, SIGNAL(finished()), this, SIGNAL(upgradeFinished()));
53
}