Commit d1622ce5 authored by Lukas Appelhans's avatar Lukas Appelhans

Fixing something

parent 747307c1
......@@ -91,7 +91,7 @@ void QueueOperation::validationFinished(bool valid)
conflict << item->requiredByTree();
}
if (!conflict.isEmpty()) {
out << i18n("The queue could not be validated, the following packages have the packages marked to be removed as dependencies: ");
out << i18n("The queue could not be validated, the following packages have the packages marked to be removed as dependencies: ");//FIXME: Pluralize
foreach (Akabei::Package* pkg, conflict) {
if (pkg != conflict.first())
out << ", ";
......
......@@ -48,7 +48,7 @@ void RemoveOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Op
} else if (!args.isEmpty()) {
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, args) {
query = query + " Name LIKE \"" + pkg + "\"";
query = query + " name=\"" + pkg + "\"";
if (args.last() != pkg)
query = query + " OR";
}
......
......@@ -73,7 +73,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
return;
connect(Akabei::Backend::instance(), SIGNAL(queryGroupsCompleted(QUuid,QList<Akabei::Group*>)),
SLOT(showGroup(QUuid,QList<Akabei::Group*>)));
Akabei::Backend::instance()->queryGroups("SELECT * FROM groups WHERE Name LIKE \"" + args.first() + "\"");
Akabei::Backend::instance()->queryGroups("SELECT * FROM groups WHERE name LIKE \"" + args.first() + "\"");
} else if (operation == APM::UpdateDatabases) {
if (AkabeiClient::Backend::instance()->databases().isEmpty())
return;
......@@ -92,27 +92,27 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
for ( ; it != locals.end(); it++) {
if (it != locals.begin())
query = query + " OR";
query = query + " Name LIKE \"" + (*it)->name() + "\"";
query = query + " name LIKE \"" + (*it)->name() + "\"";
}
connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(upgrade(QUuid,QList<Akabei::Package*>)));
Akabei::Backend::instance()->queryPackages(query);
queryId = Akabei::Backend::instance()->queryPackages(query);
} else if (!args.isEmpty()) {
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, args) {
query = query + " Name LIKE \"" + pkg + "\"";
query = query + " name LIKE \"" + pkg + "\"";
if (args.last() != pkg)
query = query + " OR";
}
connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(install(QUuid,QList<Akabei::Package*>)));
Akabei::Backend::instance()->queryPackages(query);
queryId = Akabei::Backend::instance()->queryPackages(query);
} else {
QCoreApplication::instance()->quit();
}
}
void SyncOperation::upgrade(QUuid , QList< Akabei::Package* > packages)
void SyncOperation::upgrade(QUuid uuid, QList< Akabei::Package* > packages)
{
if (packages.isEmpty())
if (packages.isEmpty() || queryId != uuid)
return;
QHash<QString, QList<Akabei::Package*> > pkgs;
foreach (Akabei::Package * pkg, packages) {
......@@ -146,13 +146,18 @@ void SyncOperation::upgrade(QUuid , QList< Akabei::Package* > packages)
connect(op, SIGNAL(finished()), QCoreApplication::instance(), SLOT(quit()));
}
void SyncOperation::install(QUuid , QList< Akabei::Package* > packages)
void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
{
if (queryId != uuid || packages.isEmpty()) {
QCoreApplication::instance()->quit();
return;
}
//FIXME: Cleanup and show all the packages and what is going to be done with them!
QTextStream out(stdout);
QMap<QString, Akabei::Package*> toBeInstalled;
QMap<QString, Akabei::Package*> local;
foreach (Akabei::Package * pkg, packages) {
qDebug() << "Queried" << pkg->name();
if (pkg->database() == Akabei::Backend::instance()->localDatabase())
local[pkg->name()] = pkg;
}
......@@ -210,7 +215,7 @@ void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
foreach (Akabei::Package * p, packages) {
if (p->database() == Akabei::Backend::instance()->localDatabase())
continue;
bool installed = Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + p->name() + "\"").isEmpty();
bool installed = !Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM packages WHERE name=\"" + p->name() + "\" AND version=\"" + p->version().toByteArray() + "\"").isEmpty();
AkabeiClient::DatabaseHandler * db = 0;
foreach (AkabeiClient::DatabaseHandler *database, AkabeiClient::Backend::instance()->databases()) {
if (database->database() == p->database()) {
......
......@@ -45,6 +45,7 @@ private:
QList<APM::Operation> m_operations;
QMultiHash<APM::Operation, QString> m_options;
QStringList m_args;
QUuid queryId;
};
#endif // SYNCOPERATION_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment