Commit dfb77ce2 authored by Lisa's avatar Lisa

Perform operation added. Akabei termination changed with nextOperation() when needed.

parent fb8425ec
...@@ -17,7 +17,17 @@ include_directories(${QT_INCLUDES} ...@@ -17,7 +17,17 @@ include_directories(${QT_INCLUDES}
${AKABEICLIENT_INCLUDE_DIR} ${AKABEICLIENT_INCLUDE_DIR}
${AKABEICORE_INCLUDE_DIR}) ${AKABEICORE_INCLUDE_DIR})
set(apm_SRCS queueoperation.cpp upgradeoperation.cpp removeoperation.cpp syncoperation.cpp apm.cpp queryoperation.cpp cmdline.cpp main.cpp) set(apm_SRCS
queueoperation.cpp
upgradeoperation.cpp
removeoperation.cpp
syncoperation.cpp
queryoperation.cpp
performoperation.cpp
apm.cpp
cmdline.cpp
main.cpp)
#qt4_automoc(${guzuta_SRCS}) #qt4_automoc(${guzuta_SRCS})
kde4_add_executable(akabei ${apm_SRCS}) kde4_add_executable(akabei ${apm_SRCS})
target_link_libraries(akabei ${KDE4_KDEUI_LIBRARY} ${KDE4_KIO_LIBRARY} ${AKABEICLIENT_LIBRARIES}) target_link_libraries(akabei ${KDE4_KDEUI_LIBRARY} ${KDE4_KIO_LIBRARY} ${AKABEICLIENT_LIBRARIES})
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "syncoperation.h" #include "syncoperation.h"
#include "removeoperation.h" #include "removeoperation.h"
#include "upgradeoperation.h" #include "upgradeoperation.h"
#include "performoperation.h"
#include <akabeiclient/akabeiclientbackend.h> #include <akabeiclient/akabeiclientbackend.h>
...@@ -66,24 +67,34 @@ void OperationManager::start() ...@@ -66,24 +67,34 @@ void OperationManager::start()
switch (m_type) { switch (m_type) {
case APM::QueryOperationType: { case APM::QueryOperationType: {
QueryOperation * query = new QueryOperation(m_operations, m_options, m_args, this); QueryOperation * query = new QueryOperation(m_operations, m_options, m_args, this);
connect(query, SIGNAL(queryFinished()), QCoreApplication::instance(), SLOT(quit()));
query->start(); query->start();
break; break;
} }
case APM::RemoveOperationType: { case APM::RemoveOperationType: {
RemoveOperation * remove = new RemoveOperation(m_operations, m_options, m_args, this); RemoveOperation * remove = new RemoveOperation(m_operations, m_options, m_args, this);
connect(remove, SIGNAL(removeFinished()), QCoreApplication::instance(), SLOT(quit()));
remove->start(); remove->start();
break; break;
} }
case APM::SyncOperationType: { case APM::SyncOperationType: {
SyncOperation * sync = new SyncOperation(m_operations, m_options, m_args, this); SyncOperation * sync = new SyncOperation(m_operations, m_options, m_args, this);
connect(sync, SIGNAL(syncFinished()), QCoreApplication::instance(), SLOT(quit()));
sync->start(); sync->start();
break; break;
} }
case APM::UpgradeOperationType: { case APM::UpgradeOperationType: {
UpgradeOperation * upgrade = new UpgradeOperation(this); UpgradeOperation * upgrade = new UpgradeOperation(this);
connect(upgrade, SIGNAL(upgradeFinished()), QCoreApplication::instance(), SLOT(quit()));
upgrade->start(m_operations, m_options, m_args); upgrade->start(m_operations, m_options, m_args);
break; break;
} }
case APM::PerformOperationType: {
PerformOperation * perform = new PerformOperation(this);
connect(perform, SIGNAL(performFinished()), QCoreApplication::instance(), SLOT(quit()));
perform->start(m_options, m_args);
break;
}
default: default:
break; break;
} }
......
...@@ -26,6 +26,7 @@ CmdLine::CmdLine() ...@@ -26,6 +26,7 @@ CmdLine::CmdLine()
typechars.insert("R", APM::RemoveOperationType); typechars.insert("R", APM::RemoveOperationType);
typechars.insert("S", APM::SyncOperationType); typechars.insert("S", APM::SyncOperationType);
typechars.insert("U", APM::UpgradeOperationType); typechars.insert("U", APM::UpgradeOperationType);
typechars.insert("P", APM::PerformOperationType);
/* /*
* The argument list is only meaningful after reading the command line, so for now it stays empty * The argument list is only meaningful after reading the command line, so for now it stays empty
...@@ -148,6 +149,17 @@ CmdLine::CmdLine() ...@@ -148,6 +149,17 @@ CmdLine::CmdLine()
upgrade.addOption(ignore); upgrade.addOption(ignore);
upgrade.addOption(ignoregroup); upgrade.addOption(ignoregroup);
AkabeiOperation perform(APM::PerformOperationType, APM::Perform, "P", "perform", "Performs a series of installations and removals", true);
perform.addOption(skipdependencycheck);
perform.addOption(force);
perform.addOption(databaseonly);
perform.addOption(removeconfig);
perform.addOption(recursive);
perform.addOption(installasdeps);
perform.addOption(installasexplicit);
perform.addOption(downloadonly);
perform.addOption(onlyneeded);
AkabeiOperation help(APM::NoType, APM::Help, "h", "help", "Shows the help message", false); AkabeiOperation help(APM::NoType, APM::Help, "h", "help", "Shows the help message", false);
AkabeiOperation version(APM::NoType, APM::Version, "v", "version", "Shows Akabei version", false); AkabeiOperation version(APM::NoType, APM::Version, "v", "version", "Shows Akabei version", false);
...@@ -155,7 +167,7 @@ CmdLine::CmdLine() ...@@ -155,7 +167,7 @@ CmdLine::CmdLine()
tmp << &updatedb << &removeallcache << &help << &version << &install << &remove << &database; tmp << &updatedb << &removeallcache << &help << &version << &install << &remove << &database;
tmp << &checkfiles << &showowner << &notrequired << &upgradeable << &cascade << &unneeded; tmp << &checkfiles << &showowner << &notrequired << &upgradeable << &cascade << &unneeded;
tmp << &removeold << &groups << &info << &listrepo << &groupsl << &searchl << &infol; tmp << &removeold << &groups << &info << &listrepo << &groupsl << &searchl << &infol;
tmp << &search << &updatesys << &upgrade << &changelog << &installedasdeps << &installedexp; tmp << &search << &updatesys << &upgrade << &changelog << &installedasdeps << &installedexp << &perform;
/* /*
* They have to be pointers otherwise the changes in this foreach * They have to be pointers otherwise the changes in this foreach
...@@ -171,7 +183,10 @@ CmdLine::CmdLine() ...@@ -171,7 +183,10 @@ CmdLine::CmdLine()
} }
/* These are the only operation we need to access directly later, so better speed up searches a bit */ /* These are the only operation we need to access directly later, so better speed up searches a bit */
specialOperations << removeallcache << help << version << install; specialOperations.insert(APM::RemoveAllCache, removeallcache);
specialOperations.insert(APM::Help, help);
specialOperations.insert(APM::Version, version);
specialOperations.insert(APM::Install, install);
} }
AkabeiOption::AkabeiOption(APM::OptionName n, const char *cs, const char *cl, const char *desc, bool hasArg) AkabeiOption::AkabeiOption(APM::OptionName n, const char *cs, const char *cl, const char *desc, bool hasArg)
...@@ -298,10 +313,10 @@ void CmdLine::parse(int argc, char** argv) ...@@ -298,10 +313,10 @@ void CmdLine::parse(int argc, char** argv)
* These are considered separately and when found, they surpass any other operation that may be present. * These are considered separately and when found, they surpass any other operation that may be present.
*/ */
if (args->isSet("h")) { if (args->isSet("h")) {
AkabeiOperation help = specialOperations[1]; AkabeiOperation help = specialOperations[APM::Help];
m_operations.insert(APM::Help, help); m_operations.insert(APM::Help, help);
} else if (args->isSet("v")) { } else if (args->isSet("v")) {
AkabeiOperation version = specialOperations[2]; AkabeiOperation version = specialOperations[APM::Version];
m_operations.insert(APM::Version, version); m_operations.insert(APM::Version, version);
} }
else { else {
...@@ -338,7 +353,7 @@ void CmdLine::parse(int argc, char** argv) ...@@ -338,7 +353,7 @@ void CmdLine::parse(int argc, char** argv)
* so we have to check it separately. Again, malformed versions will be spotted later * so we have to check it separately. Again, malformed versions will be spotted later
*/ */
if (KCmdLineArgs::allArguments().contains("-Scc")) { if (KCmdLineArgs::allArguments().contains("-Scc")) {
AkabeiOperation special = specialOperations.first(); AkabeiOperation special = specialOperations[APM::RemoveAllCache];
m_operations.insert(special.name, special); m_operations.insert(special.name, special);
found << special.commandShort; found << special.commandShort;
} }
...@@ -429,7 +444,7 @@ void CmdLine::parse(int argc, char** argv) ...@@ -429,7 +444,7 @@ void CmdLine::parse(int argc, char** argv)
* -Sy with args first updates and then installs the packages * -Sy with args first updates and then installs the packages
*/ */
if (!m_freeArgs.isEmpty() && m_operations.contains(APM::UpdateDatabases)) { if (!m_freeArgs.isEmpty() && m_operations.contains(APM::UpdateDatabases)) {
m_operations.insert(APM::Install, specialOperations.last()); m_operations.insert(APM::Install, specialOperations[APM::Install]);
} }
if (!m_freeArgs.isEmpty() && !freeArgsRequired()) { if (!m_freeArgs.isEmpty() && !freeArgsRequired()) {
......
...@@ -39,7 +39,7 @@ enum OperationName { ...@@ -39,7 +39,7 @@ enum OperationName {
UpdateDatabases, ShowChangelog, ShowInstalledAsDeps, ShowInstalledExplicitely, ShowPackagesOfGroup, UpdateDatabases, ShowChangelog, ShowInstalledAsDeps, ShowInstalledExplicitely, ShowPackagesOfGroup,
ShowPackagesOfGroupLocal, ShowInformationLocal, ShowInformation, CheckFiles, ShowOwner, ShowNotRequired, ShowUpgradeable, ShowPackagesOfGroupLocal, ShowInformationLocal, ShowInformation, CheckFiles, ShowOwner, ShowNotRequired, ShowUpgradeable,
Install, RemoveOldFromCache, RemoveAllCache, ListRepo, Search, UpdateSystem, Install, RemoveOldFromCache, RemoveAllCache, ListRepo, Search, UpdateSystem,
Remove, Cascade, Unneeded, SearchLocal, Remove, Cascade, Unneeded, SearchLocal, Perform,
DatabaseOperation, Upgrade, Help, Version DatabaseOperation, Upgrade, Help, Version
}; };
typedef enum OperationName OperationName; typedef enum OperationName OperationName;
...@@ -120,7 +120,7 @@ private: ...@@ -120,7 +120,7 @@ private:
QHash<QByteArray, APM::OperationType> typechars; QHash<QByteArray, APM::OperationType> typechars;
/* This is for the few operations that we need to access quickly later */ /* This is for the few operations that we need to access quickly later */
AkabeiOperationList specialOperations; QHash<APM::OperationName, AkabeiOperation> specialOperations;
bool parsed; bool parsed;
......
/* This file is part of the Chakra project
Copyright (C) 2011 Lisa "shainer" Vitolo <shainer@chakra-project.org>
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 "performoperation.h"
#include <iostream>
#include <QTextStream>
#include <QList>
#include <QCoreApplication>
#include <QDebug>
PerformOperation::PerformOperation(QObject* parent)
: QObject(parent)
{}
PerformOperation::~PerformOperation() {}
void PerformOperation::start(QHash<APM::OptionName, AkabeiOption> options, QStringList args)
{
m_options = options;
foreach (QString pkg, args) {
if (pkg.endsWith("+")) {
installPkgs << pkg.remove(pkg.size() - 1, pkg.size()); /* removes the suffix */
} else if (pkg.endsWith("-")) {
removePkgs << pkg.remove(pkg.size() - 1, pkg.size());
} else {
QTextStream err(stderr);
err << "akabei: Invalid package argument \"" << pkg << "\" supplied.\n";
QCoreApplication::instance()->quit();
return;
}
}
if (!installPkgs.isEmpty()) {
QList<APM::OperationName> install;
install << APM::Install;
SyncOperation *syncOp = new SyncOperation(install, m_options, installPkgs, this);
connect(syncOp, SIGNAL(syncFinished()), this, SLOT(secondStep()));
syncOp->start();
} else {
secondStep();
}
}
void PerformOperation::secondStep()
{
if (!removePkgs.isEmpty()) {
QList<APM::OperationName> remove;
remove << APM::Remove;
RemoveOperation *removeOp = new RemoveOperation(remove, m_options, removePkgs, this);
connect(removeOp, SIGNAL(removeFinished()), this, SIGNAL(performFinished()));
removeOp->start();
} else {
emit performFinished();
}
}
#include "performoperation.moc"
\ No newline at end of file
/* This file is part of the Chakra project
Copyright (C) 2011 Lisa "shainer" Vitolo <shainer@chakra-project.org>
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.
*/
#ifndef PERFORMOPERATION_H
#define PERFORMOPERATION_H
#include "apm.h"
#include "cmdline.h"
#include "syncoperation.h"
#include "removeoperation.h"
class PerformOperation : public QObject
{
Q_OBJECT
public:
explicit PerformOperation(QObject* parent = 0);
virtual ~PerformOperation();
void start(QHash<APM::OptionName, AkabeiOption> options, QStringList args);
signals:
void performFinished();
private:
QStringList removePkgs, installPkgs;
QHash<APM::OptionName, AkabeiOption> m_options;
private slots:
void secondStep();
};
#endif
\ No newline at end of file
...@@ -94,8 +94,11 @@ void QueryOperation::start() ...@@ -94,8 +94,11 @@ void QueryOperation::start()
void QueryOperation::showInformation(QList<Akabei::Package*> packages) void QueryOperation::showInformation(QList<Akabei::Package*> packages)
{ {
if (packages.isEmpty()) if (packages.isEmpty()) {
nextOperation();
return; return;
}
Akabei::Package * pkg = packages.first(); Akabei::Package * pkg = packages.first();
QTextStream out(stdout); QTextStream out(stdout);
out.setFieldWidth(20);//TODO: Use QFontMetrics to get width of longest word and use that as width of the field (Also in -Si) out.setFieldWidth(20);//TODO: Use QFontMetrics to get width of longest word and use that as width of the field (Also in -Si)
...@@ -129,7 +132,7 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups) ...@@ -129,7 +132,7 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
{ {
Q_UNUSED(uuid) Q_UNUSED(uuid)
if (groups.isEmpty()) { if (groups.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
Akabei::Group * group = groups.first(); Akabei::Group * group = groups.first();
...@@ -147,9 +150,10 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups) ...@@ -147,9 +150,10 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
void QueryOperation::showChangelog(QList< Akabei::Package* > packages) void QueryOperation::showChangelog(QList< Akabei::Package* > packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
Akabei::Package * pkg = packages.first(); Akabei::Package * pkg = packages.first();
QTextStream out(stdout); QTextStream out(stdout);
out << pkg->retrieveChangelog() << endl; out << pkg->retrieveChangelog() << endl;
...@@ -160,9 +164,10 @@ void QueryOperation::showChangelog(QList< Akabei::Package* > packages) ...@@ -160,9 +164,10 @@ void QueryOperation::showChangelog(QList< Akabei::Package* > packages)
void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages) void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
QTextStream out(stdout); QTextStream out(stdout);
QMap<QString, Akabei::Package*> sorted; QMap<QString, Akabei::Package*> sorted;
foreach (Akabei::Package * pkg, packages) foreach (Akabei::Package * pkg, packages)
...@@ -176,9 +181,10 @@ void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages) ...@@ -176,9 +181,10 @@ void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages)
void QueryOperation::checkFiles(QList<Akabei::Package*> packages) void QueryOperation::checkFiles(QList<Akabei::Package*> packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
Akabei::Package * pkg = packages.first(); Akabei::Package * pkg = packages.first();
QTextStream out(stdout); QTextStream out(stdout);
int all = 0; int all = 0;
...@@ -226,7 +232,7 @@ void QueryOperation::showOwner(const QString &query) ...@@ -226,7 +232,7 @@ void QueryOperation::showOwner(const QString &query)
if (!QFile::exists(query)) { if (!QFile::exists(query)) {
out << "File does not exists: " << query << endl; out << "File does not exists: " << query << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
foreach (Akabei::Package * pkg, Akabei::Backend::instance()->localDatabase()->packages()) { foreach (Akabei::Package * pkg, Akabei::Backend::instance()->localDatabase()->packages()) {
...@@ -234,7 +240,7 @@ void QueryOperation::showOwner(const QString &query) ...@@ -234,7 +240,7 @@ void QueryOperation::showOwner(const QString &query)
if (Akabei::Config::instance()->rootDir().absoluteFilePath(file) == query) { if (Akabei::Config::instance()->rootDir().absoluteFilePath(file) == query) {
out << query << " is owned by " << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl; out << query << " is owned by " << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
} }
...@@ -305,7 +311,7 @@ void QueryOperation::showUpgradeable() ...@@ -305,7 +311,7 @@ void QueryOperation::showUpgradeable()
void QueryOperation::nextOperation() void QueryOperation::nextOperation()
{ {
if (m_operations.isEmpty()) { if (m_operations.isEmpty()) {
QCoreApplication::instance()->quit(); emit queryFinished();
return; return;
} }
start(); start();
......
...@@ -45,6 +45,9 @@ private slots: ...@@ -45,6 +45,9 @@ private slots:
void showLocalQuery(QList<Akabei::Package*>); void showLocalQuery(QList<Akabei::Package*>);
void showNotRequired(); void showNotRequired();
void showUpgradeable(); void showUpgradeable();
signals:
void queryFinished();
}; };
#endif // QUERYOPERATION_H #endif // QUERYOPERATION_H
...@@ -61,11 +61,12 @@ void RemoveOperation::start() ...@@ -61,11 +61,12 @@ void RemoveOperation::start()
} }
void RemoveOperation::remove(QList<Akabei::Package*> packages) void RemoveOperation::remove(QList<Akabei::Package*> packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
QueueOperation *operation = new QueueOperation(APM::Remove, m_options, this); QueueOperation *operation = new QueueOperation(APM::Remove, m_options, this);
operation->start(AkabeiClient::Remove, packages); operation->start(AkabeiClient::Remove, packages);
connect(operation, SIGNAL(finished()), SLOT(nextOperation())); connect(operation, SIGNAL(finished()), SLOT(nextOperation()));
...@@ -74,7 +75,7 @@ void RemoveOperation::remove(QList<Akabei::Package*> packages) ...@@ -74,7 +75,7 @@ void RemoveOperation::remove(QList<Akabei::Package*> packages)
void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages) void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
QList<Akabei::Package*> pkgs; QList<Akabei::Package*> pkgs;
...@@ -93,9 +94,10 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages) ...@@ -93,9 +94,10 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages) void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
qDebug() << "APM::Remove" << packages.count() << "unnneeded"; qDebug() << "APM::Remove" << packages.count() << "unnneeded";
QList<Akabei::Package*> unneeded; QList<Akabei::Package*> unneeded;
foreach (Akabei::Package * pkg, packages) { foreach (Akabei::Package * pkg, packages) {
...@@ -109,7 +111,7 @@ void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages) ...@@ -109,7 +111,7 @@ void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages)
unneeded << pkg; unneeded << pkg;
} }
if (unneeded.isEmpty()) { if (unneeded.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
QueueOperation *operation = new QueueOperation(APM::Unneeded, m_options, this); QueueOperation *operation = new QueueOperation(APM::Unneeded, m_options, this);
...@@ -120,7 +122,7 @@ void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages) ...@@ -120,7 +122,7 @@ void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages)
void RemoveOperation::nextOperation() void RemoveOperation::nextOperation()
{ {
if (m_operations.isEmpty()) { if (m_operations.isEmpty()) {
QCoreApplication::instance()->quit(); emit removeFinished();
return; return;
} }
start(); start();
......
...@@ -35,6 +35,9 @@ private: ...@@ -35,6 +35,9 @@ private:
QList<APM::OperationName> m_operations; QList<APM::OperationName> m_operations;
QHash<APM::OptionName, AkabeiOption> m_options; QHash<APM::OptionName, AkabeiOption> m_options;
QStringList m_args; QStringList m_args;
signals:
void removeFinished();
}; };
#endif // REMOVEOPERATION_H #endif // REMOVEOPERATION_H
...@@ -49,13 +49,12 @@ SyncOperation::~SyncOperation() {} ...@@ -49,13 +49,12 @@ SyncOperation::~SyncOperation() {}
// we can have proper errorhandling // we can have proper errorhandling
// or let shainer write that CLI parser // or let shainer write that CLI parser
void SyncOperation::start() void SyncOperation::start()
{ {
QTextStream err(stderr); QTextStream err(stderr);
Akabei::Backend *backend = Akabei::Backend::instance(); Akabei::Backend *backend = Akabei::Backend::instance();
APM::OperationName operation = m_operations.takeFirst(); APM::OperationName operation = m_operations.takeFirst();
switch(operation) { switch(operation) {
case APM::UpdateDatabases: case APM::UpdateDatabases:
{ {
...@@ -97,7 +96,7 @@ void SyncOperation::start() ...@@ -97,7 +96,7 @@ void SyncOperation::start()
} }
case APM::Install: case APM::Install:
{ {
connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(install(QUuid,QList<Akabei::Package*>))); connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(install(QUuid,QList<Akabei::Package*>)));
queryId = backend->searchPackages(m_args, Akabei::SearchNameEqual); queryId = backend->searchPackages(m_args, Akabei::SearchNameEqual);
break; break;
...@@ -139,6 +138,7 @@ void SyncOperation::updateSystem() ...@@ -139,6 +138,7 @@ void SyncOperation::updateSystem()
void SyncOperation::upgrade(QUuid uuid, QList< Akabei::Package* > packages) void SyncOperation::upgrade(QUuid uuid, QList< Akabei::Package* > packages)
{ {
if (packages.isEmpty() || queryId != uuid) { if (packages.isEmpty() || queryId != uuid) {
nextOperation();
return; return;
} }
...@@ -175,6 +175,7 @@ void SyncOperation::upgrade(QUuid uuid, QList< Akabei::Package* > packages) ...@@ -175,6 +175,7 @@ void SyncOperation::upgrade(QUuid uuid, QList< Akabei::Package* > packages)
} }
if (toBeUpgraded.isEmpty()) { if (toBeUpgraded.isEmpty()) {
nextOperation();
return; return;
} }
...@@ -212,6 +213,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages) ...@@ -212,6 +213,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
if (packages.isEmpty()) { if (packages.isEmpty()) {
err << i18n("No appropriate packages found") << endl; err << i18n("No appropriate packages found") << endl;
err.flush(); err.flush();
nextOperation();
return; return;
} }
...@@ -238,7 +240,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages) ...@@ -238,7 +240,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
if (toBeInstalled.isEmpty() && toBeUpgraded.isEmpty() && toBeReinstalled.isEmpty()) { if (toBeInstalled.isEmpty() && toBeUpgraded.isEmpty() && toBeReinstalled.isEmpty()) {
out << i18n("No appropriate packages found") << endl; out << i18n("No appropriate packages found") << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
...@@ -289,7 +291,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages) ...@@ -289,7 +291,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
std::string input; std::string input;
getline(std::cin, input); getline(std::cin, input);
if (!input.empty() && input != i18n("y").toStdString()) { if (!input.empty() && input != i18n("y").toStdString()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
} }
...@@ -302,7 +304,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages) ...@@ -302,7 +304,7 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages) void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
QCoreApplication::instance()->quit(); nextOperation();
return; return;
} }
...@@ -345,8 +347,11 @@ void SyncOperation::listRepo(const QString &repo) ...@@ -345,8 +347,11 @@ void SyncOperation::listRepo(const QString &repo)
break; break;
} }
} }
if (!db) if (!db) {
nextOperation();
return; return;
}
QTextStream out(stdout); QTextStream out(stdout);
foreach (Akabei::Package * pkg, db->database()->packages()) { foreach (Akabei::Package * pkg, db->database()->packages()) {
Akabei::Package::List installed = Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + pkg->name() + "\""); Akabei::Package::List installed = Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + pkg->name() + "\"");
...@@ -366,6 +371,7 @@ void SyncOperation::listRepo(const QString &repo) ...@@ -366,6 +371,7 @@ void SyncOperation::listRepo(const QString &repo)
void SyncOperation::showInformation(QUuid,QList<Akabei::Package*> packages) void SyncOperation::showInformation(QUuid,QList<Akabei::Package*> packages)
{ {
if (packages.isEmpty()) { if (packages.isEmpty()) {
nextOperation();
return; return;
} }
...@@ -444,6 +450,7 @@ void SyncOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups) ...@@ -444,6 +450,7 @@ void SyncOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)