apm.cpp 1.46 KB
Newer Older
Lukas Appelhans's avatar
Lukas Appelhans committed
1 2 3 4 5 6 7 8 9 10 11
/* This file is part of the Chakra project

   Copyright (C) 2011 Lukas Appelhans <l.appelhans@gmx.de>

   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 "apm.h"

Lukas Appelhans's avatar
Lukas Appelhans committed
12 13
#include "queryoperation.h"

14 15
#include <akabeiclient/akabeiclientbackend.h>

Lukas Appelhans's avatar
Lukas Appelhans committed
16 17 18
#include <kdebug.h>
#include <QStringList>
#include <QTextStream>
19 20
#include <QCoreApplication>
#include <QTimer>
Lukas Appelhans's avatar
Lukas Appelhans committed
21

22 23 24 25 26
APM::APM(OperationType type, QList<Operation> operations, QStringList args, QObject * parent)
  : QObject(parent),
    m_operationType(type),
    m_operations(operations),
    m_args(args)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
{

    //QTimer::singleShot(0, AkabeiClient::Backend::instance(), SLOT(initialize()));
    //QCoreApplication::instance()->quit();
    //QTimer::singleShot(0, QCoreApplication::instance(), SLOT(quit()));
    connect(AkabeiClient::Backend::instance(), SIGNAL(statusChanged(Akabei::Backend::Status)), SLOT(statusChanged(Akabei::Backend::Status)));
    AkabeiClient::Backend::instance()->initialize();
}

APM::~APM()
{}

void APM::statusChanged(Akabei::Backend::Status status)
{
    if (status == Akabei::Backend::StatusReady)
        start();
}

void APM::start()
Lukas Appelhans's avatar
Lukas Appelhans committed
46
{
Lukas Appelhans's avatar
Lukas Appelhans committed
47 48 49 50
    if (m_operationType == QueryOperationType) {
        QueryOperation * query = new QueryOperation(this);
        query->start(m_operations, m_args);
    }
Lukas Appelhans's avatar
Lukas Appelhans committed
51 52 53
}

#include "apm.moc"