upgradeoperation.cpp 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* 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"

#include <kdebug.h>
#include <akabeiclientbackend.h>
#include <akabeiclientqueue.h>
#include <akabeiclienttransactionhandler.h>
#include <klocale.h>
#include <akabeiconfig.h>
#include <QFile>
#include <QDir>
#include <akabeioperationrunner.h>
#include <QCoreApplication>
Lukas Appelhans's avatar
Lukas Appelhans committed
23
#include <iostream>
24
#include "queueoperation.h"
25 26

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

}

UpgradeOperation::~UpgradeOperation()
{

}

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

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

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