Commit a184b636 authored by Lukas Appelhans's avatar Lukas Appelhans

Work on upgrading and transaction messages

parent 867254f0
......@@ -84,6 +84,17 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
}
m_currentDatabasePos = 0;
updateNextDatabase();
} else if (operation == APM::UpdateSystem) {
QString query = "SELECT * FROM packages WHERE";
QList<Akabei::Package*> locals = Akabei::Backend::instance()->localDatabase()->packages();
QList<Akabei::Package*>::iterator it = locals.begin();
for ( ; it != locals.end(); it++) {
if (it != locals.begin())
query = query + " OR";
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);
} else if (!args.isEmpty()) {
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, args) {
......@@ -98,6 +109,52 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
}
}
void SyncOperation::upgrade(QUuid , QList< Akabei::Package* > packages)
{
QHash<QString, QList<Akabei::Package*> > pkgs;
foreach (Akabei::Package * pkg, packages) {
pkgs[pkg->name()].append(pkg);
}
QList<Akabei::Package*> toBeUpgraded;
foreach (const QString &pkg, pkgs.keys()) {
QList<Akabei::Package*> candidates = pkgs[pkg];
if (!candidates.isEmpty()) {
QMap<Akabei::Package::Version, Akabei::Package*> versions;
Akabei::Package * local = 0;
foreach (Akabei::Package* p, candidates) {
if (p->database() == Akabei::Backend::instance()->localDatabase())
local = p;
else
versions[p->version()] = p;
}
if (!local) //Something obviously is wrong here
continue;
if (!versions.isEmpty() && versions.values().last()->version() > local->version()) {
toBeUpgraded << candidates.last();
kDebug() << "To be upgraded" << candidates.last()->name();
}
}
}
foreach (Akabei::Package * pkg, toBeUpgraded) {
AkabeiClient::Backend::instance()->queue()->addPackage(pkg, AkabeiClient::Update);
}
Akabei::ProcessingOptions options;
if (m_operations.contains(APM::Force))
options |= Akabei::Force;
if (m_operations.contains(APM::AsDeps))
options |= Akabei::InstallAsDependencies;
if (m_operations.contains(APM::AsExplicit))
options |= Akabei::InstallAsExplicit;
if (m_operations.contains(APM::SkipDependencyCheck))
options |= Akabei::SkipDependencies;
if (m_operations.contains(APM::DownloadOnly))
options |= Akabei::DownloadOnly;
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(validationFinished(bool)), SLOT(validationFinished(bool)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(errorsOccurred(QList<Akabei::Error*>&)), SLOT(errors(QList<Akabei::Error*>&)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(newTransactionMessage(QString)), SLOT(transactionMessage(QString)));
AkabeiClient::Backend::instance()->transactionHandler()->validate(options);
}
void SyncOperation::install(QUuid , QList< Akabei::Package* > packages)
{
QTextStream out(stdout);
......@@ -158,6 +215,7 @@ void SyncOperation::install(QUuid , QList< Akabei::Package* > packages)
options |= Akabei::DownloadOnly;
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(validationFinished(bool)), SLOT(validationFinished(bool)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(errorsOccurred(QList<Akabei::Error*>&)), SLOT(errors(QList<Akabei::Error*>&)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(newTransactionMessage(QString)), SLOT(transactionMessage(QString)));
AkabeiClient::Backend::instance()->transactionHandler()->validate(options);
}
......@@ -248,6 +306,12 @@ void SyncOperation::errors(QList<Akabei::Error*>& errors)
out.flush();
}
void SyncOperation::transactionMessage(const QString& message)
{
QTextStream out(stdout);
out << message << endl;
}
void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
{
if (packages.isEmpty())
......
......@@ -38,7 +38,9 @@ private slots:
void validationFinished(bool valid);
void showProgress(int);
void errors(QList<Akabei::Error*>& errors);
void transactionMessage(const QString &message);
void finished();
void upgrade(QUuid,QList<Akabei::Package*>);
private:
int m_currentDatabasePos;
......
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