Commit d8ce853a authored by Dario Freddi's avatar Dario Freddi
Browse files

More stuff around, and actually change the schema


Signed-off-by: default avatarDario Freddi <drf@kde.org>
parent e3fbb877
......@@ -5,7 +5,7 @@ CREATE TABLE packages (
"Description" TEXT,
"Groups" TEXT,
"Size" INTEGER,
"HasScriptlet" INTEGER,
"Scriptlet" STRING,
"Hooks" TEXT,
"MD5SUM" TEXT,
"URL" TEXT,
......
......@@ -368,6 +368,12 @@ QUuid Backend::searchPackages(const QString& token)
return queryPackages(sql);
}
OperationRunner* Backend::operationRunner()
{
Q_D(Backend);
return d->runner;
}
}
#include "akabeibackend.moc"
......@@ -17,6 +17,7 @@
#include "akabeicore_global.h"
namespace Akabei {
class OperationRunner;
class Group;
class Package;
class Database;
......@@ -56,6 +57,8 @@ class AKABEICORESHARED_EXPORT Backend : public QObject
QUuid queryPackages(const QString &sql);
QUuid queryGroups(const QString &sql);
OperationRunner *operationRunner();
Q_SIGNALS:
void statusChanged(Akabei::Backend::Status status);
void queryPackagesCompleted(const QUuid &id, const QList<Akabei::Package*> &result);
......
......@@ -15,6 +15,7 @@
#include <QtCore/QFileSystemWatcher>
#include <QtCore/QFutureWatcher>
#include "akabeioperationrunner.h"
namespace Akabei
{
......@@ -47,7 +48,8 @@ class BackendPrivate : public QObject
, q_ptr(p)
, status(Backend::StatusBare)
, fsWatcher(new QFileSystemWatcher(p))
, groupPool(new GroupPool) {}
, groupPool(new GroupPool)
, runner(new OperationRunner(p)) {}
~BackendPrivate() {
delete groupPool;
}
......@@ -64,6 +66,8 @@ class BackendPrivate : public QObject
QHash< QUuid, QFutureWatcher< QList < Package* > >* > queryPackageFuturePool;
QHash< QUuid, QFutureWatcher< QList < Group* > >* > queryGroupFuturePool;
OperationRunner *runner;
void __k__initializationFinished();
QHash<QString, Database*> performInitialization();
......
......@@ -32,7 +32,7 @@ namespace Packages {
const int DESCRIPTION = 3;
const int GROUPS = 4;
const int SIZE = 5;
const int HASSCRIPTLET = 6;
const int SCRIPTLET = 6;
const int HOOKS = 7;
const int MD5SUM = 8;
const int URL = 9;
......
......@@ -50,7 +50,8 @@ DatabasePrivate::~DatabasePrivate()
QString Database::name() const
{
Q_D(const Database);
return d->pathToDb;
}
void DatabasePrivate::populateGroupCache()
......@@ -80,8 +81,6 @@ void DatabasePrivate::populateGroupCache()
Group *DatabasePrivate::groupFromRow(sqlite3_stmt *stmt)
{
Q_Q(Database);
using namespace Tables::Groups;
QString name = QSTRING_FROM_DB(stmt, NAME);
......@@ -121,7 +120,7 @@ Package *DatabasePrivate::packageFromRow(sqlite3_stmt *stmt)
package->d_func()->buildDate = QDateTime::fromTime_t(sqlite3_column_int(stmt, Tables::Packages::BUILDDATE));
package->d_func()->desc = QSTRING_FROM_DB(stmt, DESCRIPTION);
package->d_func()->files = QString(QSTRING_FROM_DB(stmt, FILES)).split(';');
package->d_func()->hasScriptlet = sqlite3_column_int(stmt, Tables::Packages::HASSCRIPTLET) > 0 ? true : false;
package->d_func()->scriptlet = QSTRING_FROM_DB(stmt, SCRIPTLET);
package->d_func()->hooks = QSTRING_FROM_DB(stmt, HOOKS).split(';');
package->d_func()->md5sum = QSTRING_FROM_DB(stmt, MD5SUM);
package->d_func()->mimetypes = QSTRING_FROM_DB(stmt, PROVIDESMIMETYPE).split(';');
......@@ -130,6 +129,8 @@ Package *DatabasePrivate::packageFromRow(sqlite3_stmt *stmt)
package->d_func()->size = sqlite3_column_int64(stmt, Tables::Packages::SIZE);
package->d_func()->url = QSTRING_FROM_DB(stmt, URL);
package->d_func()->version = Package::Version(QSTRING_FROM_DB(stmt, VERSION));
package->d_func()->conflicts = QSTRING_FROM_DB(stmt, CONFLICTS).split(';');
package->d_func()->deps = QSTRING_FROM_DB(stmt, DEPENDS).split(';');
// Groups
foreach (const QString &group, QSTRING_FROM_DB(stmt, GROUPS).split(';')) {
......
......@@ -10,6 +10,7 @@
#include "akabeigroup_p.h"
#include "akabeibackend.h"
#include "akabeihelpers_p.h"
namespace Akabei
{
......@@ -45,14 +46,24 @@ QString Group::iconName() const
QList< Akabei::Package* > Group::packages()
{
Q_D(Group);
// return Backend::instance()->queryPackages("SELECT * FROM packages WHERE Groups LIKE \"%;" + d->name + ";%\"");
Helpers::PackageEventLoop e;
e.connect(Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
&e, SLOT(requestQuit(QUuid,QList<Akabei::Package*>)));
e.setUuid(Backend::instance()->queryPackages("SELECT * FROM packages WHERE Groups LIKE \"%;" + d->name + ";%\""));
e.exec();
return e.result();
}
QList< Package* > Group::search(const QString& token)
{
Q_D(Group);
// return Backend::instance()->queryPackages("SELECT * FROM packages WHERE Groups LIKE \"%;" + d->name + ";%\" AND "
// "(Name LIKE \"%" + token + "%\" OR Description LIKE \"%" + token + "%\")");
Helpers::PackageEventLoop e;
e.connect(Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
&e, SLOT(requestQuit(QUuid,QList<Akabei::Package*>)));
e.setUuid(Backend::instance()->queryPackages("SELECT * FROM packages WHERE Groups LIKE \"%;" + d->name + ";%\" AND "
"(Name LIKE \"%" + token + "%\" OR Description LIKE \"%" + token + "%\")"));
e.exec();
return e.result();
}
}
......
......@@ -9,7 +9,8 @@
*/
#include "akabeioperation_p.h"
#include <qeventloop.h>
#include <QEventLoop>
namespace Akabei {
......@@ -120,7 +121,7 @@ QStringList Operation::targetDependencies() const
QString Operation::targetVersion() const
{
Q_D(const Operation);
d->targetVersion;
return d->targetVersion;
}
void Operation::setCanBeConcurrent(bool concurrent)
......
......@@ -66,6 +66,8 @@ private:
Q_PRIVATE_SLOT(d_func(), void __k__errorsOccurred(QList<Error*>))
Q_PRIVATE_SLOT(d_func(), void __k__validationFinished(bool,QHash<Operation::Phase,QList<Operation*> >))
friend class BackendPrivate;
};
}
......
......@@ -27,7 +27,7 @@ Package::Version::Version(const QString& version)
Package::Version::~Version()
{
delete d;
}
QString Package::Version::toString() const
......@@ -56,11 +56,14 @@ bool Package::Version::respectsConstraint(const QString& cV) const
// The version must be the same
return *this == cV;
}
// Please the compiler
}
Package::Version& Package::Version::operator=(const Akabei::Package::Version& other)
{
d->repr = other.d->repr;
return *this;
}
bool Package::Version::operator!=(const Akabei::Package::Version& other) const
......@@ -96,6 +99,7 @@ bool Package::Version::operator>=(const Akabei::Package::Version& other) const
Package::Version& Package::Version::operator=(const QString& other)
{
d->repr = other;
return *this;
}
bool Package::Version::operator!=(const QString& other) const
......@@ -160,27 +164,24 @@ QDateTime Package::buildDate() const
QString Package::retrieveChangelog() const
{
return QString();
}
QString Package::retrieveLoggedActions() const
{
return QString();
}
QStringList Package::conflictsWith() const
{
}
QStringList Package::computeUnresolvedDependencies()
{
Q_D(const Package);
return d->conflicts;
}
Package::List Package::computeDependencies()
{
Q_D(Package);
//d->
}
Package::List Package::computeRequiredBy()
......@@ -224,54 +225,58 @@ QList< Group* > Package::groups() const
return d->groups;
}
bool Package::hasScriptlet() const
{
}
QStringList Package::hooks() const
{
Q_D(const Package);
return d->hooks;
}
bool Package::isValid() const
{
Q_D(const Package);
return d;
}
QString Package::md5sum() const
{
Q_D(const Package);
return d->md5sum;
}
QStringList Package::mimetypes() const
{
Q_D(const Package);
return d->mimetypes;
}
QString Package::packager() const
{
Q_D(const Package);
return d->packager;
}
QString Package::pathToArchive() const
{
Q_D(const Package);
return d->archive;
}
QStringList Package::provides() const
{
Q_D(const Package);
return d->providers;
}
qint32 Package::size() const
{
Q_D(const Package);
return d->size;
}
QString Package::url() const
{
Q_D(const Package);
return d->url;
}
Package::Version Package::version() const
......@@ -280,9 +285,22 @@ Package::Version Package::version() const
return d->version;
}
void Package::setPathToArchive(const QString& path)
QStringList Package::dependencies() const
{
Q_D(const Package);
return d->deps;
}
QString Package::scriptlet() const
{
Q_D(const Package);
return d->scriptlet;
}
void Package::setPathToArchive(const QString& path)
{
Q_D(Package);
d->archive = path;
}
}
......@@ -81,19 +81,18 @@ public:
QString packager() const;
QString md5sum() const;
QString arch() const;
bool hasScriptlet() const;
QString scriptlet() const;
QDateTime buildDate() const;
qint32 size() const;
QStringList files() const;
QStringList hooks() const;
QStringList computeUnresolvedDependencies();
List computeDependencies();
List computeRequiredBy();
QList<Group*> groups() const;
QStringList provides() const;
QStringList dependencies() const;
QStringList conflictsWith() const;
Database *database();
......
......@@ -34,10 +34,12 @@ public:
QString packager;
QString md5sum;
QString arch;
bool hasScriptlet;
QDateTime buildDate;
qint32 size;
QStringList files;
QStringList deps;
QStringList conflicts;
QString scriptlet;
QStringList providers;
QStringList mimetypes;
......
......@@ -29,7 +29,7 @@ namespace Akabei {
QString queryFromName(const QString &name)
{
QString sql = "SELECT * FROM packages WHERE Name = \"%1\" OR Provides LIKE \"%u;%1;%u\"";
QString sql = "SELECT * FROM packages WHERE Name = \"%1\" OR Provides LIKE \"%;%1;%\"";
sql.arg(name);
return sql;
}
......@@ -378,4 +378,4 @@ void ValidatorThread::manageErrors(const QList< Error* >& errors)
emit validationFinished(false, QHash<Operation::Phase, QList< Operation* > >());
}
}
\ No newline at end of file
}
......@@ -74,7 +74,7 @@ void PlainInstallOperation::validate()
bool found = false;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
if (archive_entry_pathname(entry) == ".PKGINFO") {
if (QString(archive_entry_pathname(entry)) == ".PKGINFO") {
}
archive_read_data_skip(a); // Note 2
}
......@@ -99,18 +99,11 @@ void PlainInstallOperation::validate()
setTargetAdditions(targets);
// If it has a scriptlet, we need a new suboperation
if (d->package->hasScriptlet()) {
if (!d->package->scriptlet().isEmpty()) {
//TODO: add scriptlet
}
// Compute dependencies and stuff
// Any unresolved dependencies?
if (!d->package->computeUnresolvedDependencies().isEmpty()) {
// Utter fail.
setValidationFinished(false);
return;
}
Package::List depends = d->package->computeDependencies();
QStringList stringDeps;
foreach (Package *p, depends) {
......
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