Commit bf92c8dd authored by Fabian Kosmale's avatar Fabian Kosmale
Browse files

clazy: autofix: fix-fromCharPtrAllocations, fix-qlatin1string-allocations

parent d57b9015
......@@ -86,7 +86,7 @@ QVariant SQLiteResource::getDataAt(int rowNumber, const QString& columnName)
{
QMutexLocker locker(&d->mutex);
if (d->table.isEmpty() || rowNumber >= d->table.size() || d->table[rowNumber].count(columnName) == 0) {
std::string error = QString("Access to non-existent data. Trying to access %1.").arg(columnName).toStdString();
std::string error = QStringLiteral("Access to non-existent data. Trying to access %1.").arg(columnName).toStdString();
throw SQLiteException(error.c_str());
}
......
......@@ -79,15 +79,15 @@ void PolKitSQLiteConnection::connectToDB(QString const& name, bool readonly)
SQLiteResource PolKitSQLiteConnection::query(const QString &q)
{
if ((d->access.testFlag(Akabei::Helpers::ReadWritePermission)) || ((d->access.testFlag(Akabei::Helpers::ReadPermission)) && q.startsWith("SELECT"))) {
if ((d->access.testFlag(Akabei::Helpers::ReadWritePermission)) || ((d->access.testFlag(Akabei::Helpers::ReadPermission)) && q.startsWith(QLatin1String("SELECT")))) {
d->lastQueryDBus = false;
return d->connection->query(q);
}
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.sqlite.query")) {
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/sqlite", "org.chakraproject.akabeicorehelper.sqlite", QDBusConnection::systemBus());
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.sqlite.query"))) {
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/sqlite"), QStringLiteral("org.chakraproject.akabeicorehelper.sqlite"), QDBusConnection::systemBus());
SETUP_DBUS_DATABASE
QDBusMessage mes = iface.call("query", q);
QDBusMessage mes = iface.call(QStringLiteral("query"), q);
d->lastQueryDBus = true;
if (!mes.arguments().isEmpty()) {
const QDBusArgument arg = mes.arguments().first().value<QDBusArgument>();
......@@ -106,15 +106,15 @@ SQLiteResource PolKitSQLiteConnection::query(const QString &q)
void PolKitSQLiteConnection::query(const QString &q, const QVariantMap &bindings)
{
if ((d->access.testFlag(Akabei::Helpers::ReadWritePermission)) || ((d->access.testFlag(Akabei::Helpers::ReadPermission)) && q.startsWith("SELECT"))) {
if ((d->access.testFlag(Akabei::Helpers::ReadWritePermission)) || ((d->access.testFlag(Akabei::Helpers::ReadPermission)) && q.startsWith(QLatin1String("SELECT")))) {
d->connection->query(q, bindings);
d->lastQueryDBus = false;
return;
}
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.sqlite.query")) {
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/sqlite", "org.chakraproject.akabeicorehelper.sqlite", QDBusConnection::systemBus());
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.sqlite.query"))) {
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/sqlite"), QStringLiteral("org.chakraproject.akabeicorehelper.sqlite"), QDBusConnection::systemBus());
SETUP_DBUS_DATABASE
QDBusMessage mes = iface.call("query", q, bindings);
QDBusMessage mes = iface.call(QStringLiteral("query"), q, bindings);
d->lastQueryDBus = true;
} else {
Akabei::ErrorQueue::instance()->appendError(
......@@ -127,11 +127,11 @@ qint64 PolKitSQLiteConnection::getLastRowId()
if (!d->lastQueryDBus)
return d->connection->getLastRowId();
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/sqlite", "org.chakraproject.akabeicorehelper.sqlite", QDBusConnection::systemBus());
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/sqlite"), QStringLiteral("org.chakraproject.akabeicorehelper.sqlite"), QDBusConnection::systemBus());
SETUP_DBUS_DATABASE
QDBusMessage mes = iface.call("lastRowId");
QDBusMessage mes = iface.call(QStringLiteral("lastRowId"));
if (!mes.arguments().isEmpty())
return mes.arguments().first().toInt();
return -1;
......@@ -147,11 +147,11 @@ void PolKitSQLiteConnection::bind(QString const& key, int value)
//We bind to both databases, as we have no information yet if we have a read or write query
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/sqlite", "org.chakraproject.akabeicorehelper.sqlite", QDBusConnection::systemBus());
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/sqlite"), QStringLiteral("org.chakraproject.akabeicorehelper.sqlite"), QDBusConnection::systemBus());
SETUP_DBUS_DATABASE
QDBusMessage mes = iface.call("bind", key, value);
QDBusMessage mes = iface.call(QStringLiteral("bind"), key, value);
}
void PolKitSQLiteConnection::bind(QString const& key, QString const& value)
......@@ -164,11 +164,11 @@ void PolKitSQLiteConnection::bind(QString const& key, QString const& value)
//We bind to both databases, as we have no information yet if we have a read or write query
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/sqlite", "org.chakraproject.akabeicorehelper.sqlite", QDBusConnection::systemBus());
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/sqlite"), QStringLiteral("org.chakraproject.akabeicorehelper.sqlite"), QDBusConnection::systemBus());
SETUP_DBUS_DATABASE
QDBusMessage mes = iface.call("bind", key, value);
QDBusMessage mes = iface.call(QStringLiteral("bind"), key, value);
}
void PolKitSQLiteConnection::bind(QString const& key, QByteArray const& value)
......@@ -181,9 +181,9 @@ void PolKitSQLiteConnection::bind(QString const& key, QByteArray const& value)
//We bind to both databases, as we have no information yet if we have a read or write query
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/sqlite", "org.chakraproject.akabeicorehelper.sqlite", QDBusConnection::systemBus());
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/sqlite"), QStringLiteral("org.chakraproject.akabeicorehelper.sqlite"), QDBusConnection::systemBus());
SETUP_DBUS_DATABASE
QDBusMessage mes = iface.call("bind", key, value);
QDBusMessage mes = iface.call(QStringLiteral("bind"), key, value);
}
......@@ -171,7 +171,7 @@ QHash<QString, Database*> BackendPrivate::performInitialization()
return QHash<QString, Database*>();
}
Database* localDb = new Database( dbDir.absoluteFilePath("local.db") );
Database* localDb = new Database( dbDir.absoluteFilePath(QStringLiteral("local.db")) );
if (!localDb->isValid()) {
qDebug() << "Local db";
......@@ -183,7 +183,7 @@ QHash<QString, Database*> BackendPrivate::performInitialization()
}
// Ok, add it to our rethash
rethash.insert("local", localDb);
rethash.insert(QStringLiteral("local"), localDb);
// Now process all the various databases
foreach (QString const& db, Config::instance()->databases()) {
......@@ -201,7 +201,7 @@ QHash<QString, Database*> BackendPrivate::performInitialization()
void BackendPrivate::addDatabase(const QString &name)
{
if (name == "local") {
if (name == QLatin1String("local")) {
return;
}
......@@ -226,18 +226,18 @@ void Backend::setStatus(Backend::Status s, QObject * cO, const char * cS)
if (Config::instance()->needsPrivileges()) {
akabeiDebug() << "We need privileges to get lock";
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.filesystem.lock")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.filesystem.lock"))) {
setStatus(Backend::StatusWaitingForLock);
akabeiDebug() << "Authorization granted";
if (!d->iface) {
d->iface = new QDBusInterface("org.chakraproject.akabeicorehelper", "/filesystem", "org.chakraproject.akabeicorehelper.filesystem", QDBusConnection::systemBus());
d->iface = new QDBusInterface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/filesystem"), QStringLiteral("org.chakraproject.akabeicorehelper.filesystem"), QDBusConnection::systemBus());
}
d->iface->setProperty("root", Config::instance()->root());
connect(d->iface, SIGNAL(lockGranted(qlonglong)), SLOT(__k__lockGranted(qlonglong)));
d->iface->asyncCall("getLock", QCoreApplication::applicationPid());
d->iface->asyncCall(QStringLiteral("getLock"), QCoreApplication::applicationPid());
} else {
akabeiDebug() << "Authorization not granted" << PolkitQt1::Authority::instance()->errorDetails();
Akabei::ErrorQueue::instance()->appendError(Error(Error::PermissionError, tr("An authorization error occurred: %1").arg(PolkitQt1::Authority::instance()->errorDetails())));
......@@ -250,10 +250,10 @@ void Backend::setStatus(Backend::Status s, QObject * cO, const char * cS)
akabeiDebug() << "We have privileges, now try get the lock";
if (!d->lockFileHandle) {
d->lockFileHandle = new QFile(Akabei::Config::instance()->rootDir().absoluteFilePath("var/local/akabei.lck"));
d->lockFileHandle = new QFile(Akabei::Config::instance()->rootDir().absoluteFilePath(QStringLiteral("var/local/akabei.lck")));
if (!d->lockFileHandle->open(QFile::ReadWrite)) {
ErrorQueue::instance()->appendError( Error(Error::PermissionError, "Could not open lock file for writing") );
ErrorQueue::instance()->appendError( Error(Error::PermissionError, QStringLiteral("Could not open lock file for writing")) );
setStatus(Backend::StatusBroken);
return;
}
......@@ -283,11 +283,11 @@ void Backend::setStatus(Backend::Status s, QObject * cO, const char * cS)
} else if (d->status == StatusOnTransaction) {
if (Config::instance()->needsPrivileges()) {
akabeiDebug() << "We need privileges to remove lock";
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.filesystem.lock")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.filesystem.lock"))) {
akabeiDebug() << "Authorization granted";
disconnect(d->iface, SIGNAL(lockGranted(qlonglong)), this, SLOT(__k__lockGranted(qlonglong)));
QDBusMessage mes = d->iface->call("removeLock", QCoreApplication::applicationPid());
QDBusMessage mes = d->iface->call(QStringLiteral("removeLock"), QCoreApplication::applicationPid());
} else {
akabeiDebug() << "Authorization not granted" << PolkitQt1::Authority::instance()->errorDetails();
setStatus(Backend::StatusBroken);
......@@ -333,7 +333,7 @@ void BackendPrivate::__k__initializationFinished()
return;
}
localDatabase = rethash["local"];
localDatabase = rethash[QStringLiteral("local")];
if (!localDatabase) {
// Something very wrong here
q->setStatus(Akabei::Backend::StatusBroken);
......@@ -343,7 +343,7 @@ void BackendPrivate::__k__initializationFinished()
// All the rest
// TODO: check if this can be done with copy_if
for (QHash< QString, Database* >::const_iterator i = rethash.constBegin(); i != rethash.constEnd(); ++i) {
if (i.key() == "local") {
if (i.key() == QLatin1String("local")) {
// Skip
continue;
}
......@@ -548,7 +548,7 @@ Backend::~Backend()
void Backend::setLocale(const QString& locale)
{
auto translator = new QTranslator(this);
translator->load("akabeicore_" + locale + ".qm", "/usr/share/akabeicore/translations/");//FIXME: Use translations from install dir
translator->load("akabeicore_" + locale + ".qm", QStringLiteral("/usr/share/akabeicore/translations/"));//FIXME: Use translations from install dir
QCoreApplication::instance()->installTranslator(translator);
}
......@@ -672,7 +672,7 @@ QUuid Backend::orphanPackages()
QUuid Backend::searchGroups(const QString& token)
{
return queryGroups( Queries::selectPackagesNameOrDescription("%" + token + "%", "LIKE") );
return queryGroups( Queries::selectPackagesNameOrDescription("%" + token + "%", QStringLiteral("LIKE")) );
}
//TODO: Maybe abstract the query generation, because the same is used in database as well
......@@ -682,22 +682,22 @@ QUuid Backend::searchPackages(const QString& token, SearchType type)
switch (type) {
case SearchNameLike:
sql = Queries::selectPackages("name", "LIKE", "%" + token + "%");
sql = Queries::selectPackages(QStringLiteral("name"), QStringLiteral("LIKE"), "%" + token + "%");
break;
case SearchNameEqual:
sql = Queries::selectPackages("name", "=", token);
sql = Queries::selectPackages(QStringLiteral("name"), QStringLiteral("="), token);
break;
case SearchDescriptionLike:
sql = Queries::selectPackages("description", "LIKE", "%" + token + "%");
sql = Queries::selectPackages(QStringLiteral("description"), QStringLiteral("LIKE"), "%" + token + "%");
break;
case SearchDescriptionEqual:
sql = Queries::selectPackages("description", "=", token);
sql = Queries::selectPackages(QStringLiteral("description"), QStringLiteral("="), token);
break;
case SearchNameAndDescriptionLike:
sql = Queries::selectPackagesNameOrDescription("%" + token + "%", "LIKE");
sql = Queries::selectPackagesNameOrDescription("%" + token + "%", QStringLiteral("LIKE"));
break;
case SearchNameAndDescriptionEqual:
sql = Queries::selectPackagesNameOrDescription(token, "=");
sql = Queries::selectPackagesNameOrDescription(token, QStringLiteral("="));
break;
}
return queryPackages(sql);
......@@ -705,7 +705,7 @@ QUuid Backend::searchPackages(const QString& token, SearchType type)
QUuid Backend::searchPackages(const QStringList &pkgs, SearchType type)
{
QString sql = "SELECT * FROM packages WHERE ";
QString sql = QStringLiteral("SELECT * FROM packages WHERE ");
for (QStringList::const_iterator it = pkgs.begin(); it < pkgs.end(); it++) {
switch (type) {
......@@ -729,7 +729,7 @@ QUuid Backend::searchPackages(const QStringList &pkgs, SearchType type)
}
if ((it + 1) != pkgs.end()) {
sql += "OR ";
sql += QLatin1String("OR ");
}
}
......@@ -785,41 +785,41 @@ Package* Backend::loadPackageFromFile(const QString& path)
value = value.simplified();
// Ok, now let's analyze
if (key == "pkgname") {
if (key == QLatin1String("pkgname")) {
retpackage->d_func()->setName(value);
} else if (key == "pkgver") {
} else if (key == QLatin1String("pkgver")) {
retpackage->d_func()->setVersion(Package::Version(value.toUtf8()));
} else if (key == "pkgdesc") {
} else if (key == QLatin1String("pkgdesc")) {
retpackage->d_func()->setDescription(value);
} else if (key == "group") {
} else if (key == QLatin1String("group")) {
retpackage->d_func()->addGroup(d->groupPool->group(value));
} else if (key == "url") {
} else if (key == QLatin1String("url")) {
retpackage->d_func()->setUrl(QUrl(value));
} else if (key == "license") {
} else if (key == QLatin1String("license")) {
retpackage->d_func()->addLicense(value);
} else if (key == "builddate") {
} else if (key == QLatin1String("builddate")) {
retpackage->d_func()->setBuildDate(QDateTime::fromTime_t(value.toUInt()));
} else if (key == "packager") {
} else if (key == QLatin1String("packager")) {
retpackage->d_func()->setPackager(value);
} else if (key == "arch") {
} else if (key == QLatin1String("arch")) {
retpackage->d_func()->setArch(value);
} else if (key == "size") {
} else if (key == QLatin1String("size")) {
retpackage->d_func()->setSize(value.toInt());
} else if (key == "depend") {
} else if (key == QLatin1String("depend")) {
retpackage->d_func()->addDependency(value);
} else if (key == "makedepend") {
} else if (key == QLatin1String("makedepend")) {
retpackage->d_func()->addMakeDependency(value);
} else if (key == "optdepend") {
} else if (key == QLatin1String("optdepend")) {
retpackage->d_func()->addOptDependency(value);
} else if (key == "conflict") {
} else if (key == QLatin1String("conflict")) {
retpackage->d_func()->addConflict(value);
} else if (key == "replaces") {
} else if (key == QLatin1String("replaces")) {
retpackage->d_func()->addReplaces(value);
} else if (key == "provides") {
} else if (key == QLatin1String("provides")) {
retpackage->d_func()->addProvider(value);
} else if (key == "hook") {
} else if (key == QLatin1String("hook")) {
retpackage->d_func()->addHook(value);
} else if (key == "backup") {
} else if (key == QLatin1String("backup")) {
/*
* TODO: make the application know why the md5 function failed
......@@ -828,35 +828,35 @@ Package* Backend::loadPackageFromFile(const QString& path)
if (!md5.isEmpty()) {
retpackage->d_func()->addBackup(value, md5);
}
} else if (key == "ultimateowner") {
} else if (key == QLatin1String("ultimateowner")) {
retpackage->d_func()->addUltimatelyOwnedFile(value);
} else if (key == "makepkgopt") {
} else if (key == QLatin1String("makepkgopt")) {
// retpackage->d_func()->arch = value;
} else if (key == "screenshot") {
} else if (key == QLatin1String("screenshot")) {
retpackage->d_func()->setScreenshot(QUrl(value));
} else if (key == "mimetype") {
} else if (key == QLatin1String("mimetype")) {
retpackage->d_func()->addMimetype(value);
} else if (key == "hook") {
} else if (key == QLatin1String("hook")) {
retpackage->d_func()->addHook(value);
} else if (key == "epoch") {
} else if (key == QLatin1String("epoch")) {
retpackage->d_func()->setEpoch(value.toInt());
} else if (key == "gitfolder") {
} else if (key == QLatin1String("gitfolder")) {
retpackage->d_func()->setGitFolder(value);
} else if (key == "gitrepository") {
} else if (key == QLatin1String("gitrepository")) {
retpackage->d_func()->setGitRepo(value);
} else if (key == "gitbranch") {
} else if (key == QLatin1String("gitbranch")) {
retpackage->d_func()->setGitBranch(value);
} else if (key == "gitrepo") { //This is legacy support
QStringList split = value.split("-");
} else if (key == QLatin1String("gitrepo")) { //This is legacy support
QStringList split = value.split(QStringLiteral("-"));
if (!split.isEmpty()) {
retpackage->d_func()->setGitRepo(split.takeFirst());
retpackage->d_func()->setGitBranch(split.isEmpty() ? "master" : split.first());
retpackage->d_func()->setGitBranch(split.isEmpty() ? QStringLiteral("master") : split.first());
}
}
}
if (pkg.getEntries().contains(".INSTALL")) {
retpackage->d_func()->setScriptlet(pkg.readTextFile(".INSTALL"));
if (pkg.getEntries().contains(QStringLiteral(".INSTALL"))) {
retpackage->d_func()->setScriptlet(pkg.readTextFile(QStringLiteral(".INSTALL")));
}
int isize = 0;
......@@ -904,7 +904,7 @@ Delta* Backend::loadDeltaFromFile(const QString& path)
try {
/* It can be only our delta */
foreach (QString const& entry, delta.getEntries()) {
if (entry != ".DELTAINFO" && entry != "." && entry != path.split('/').last().remove(".tar.xz")) {
if (entry != QLatin1String(".DELTAINFO") && entry != QLatin1String(".") && entry != path.split('/').last().remove(QStringLiteral(".tar.xz"))) {
return nullptr;
}
}
......@@ -936,11 +936,11 @@ Delta* Backend::loadDeltaFromFile(const QString& path)
value = value.simplified();
// Ok, now let's analyze
if (key == "pkgname") {
if (key == QLatin1String("pkgname")) {
retdelta->d_func()->name = value;
} else if (key == "verfrom") {
} else if (key == QLatin1String("verfrom")) {
retdelta->d_func()->vFrom = value.toUtf8();
} else if (key == "verto") {
} else if (key == QLatin1String("verto")) {
retdelta->d_func()->vTo = value.toUtf8();
}
}
......@@ -983,11 +983,11 @@ Group* Backend::loadGroupFromFile(const QString &path)
continue;
}
if (split.first() == "Name") {
if (split.first() == QLatin1String("Name")) {
group = d->groupPool->group(split.last());
} else if (group != nullptr && split.first() == "Description") {
} else if (group != nullptr && split.first() == QLatin1String("Description")) {
group->d_ptr->setDescription(split.last());
} else if (group != nullptr && split.first() == "Iconname") {
} else if (group != nullptr && split.first() == QLatin1String("Iconname")) {
group->d_ptr->setIcon(split.last());
}
}
......@@ -1002,7 +1002,7 @@ Hook* Backend::loadHookFromFile(const QString& path, QList<Package*> pkgs)
return nullptr;
}
QString name( path.split('/').last().remove(".hook") );
QString name( path.split('/').last().remove(QStringLiteral(".hook")) );
QTextStream in( &file );
return new Hook(name, in.readAll(), pkgs);
......
......@@ -124,7 +124,7 @@ void Cache::Private::init()
* Create a new list of cache entries with their full path.
*/
foreach (QString const& cacheFile, plainEntryList) {
if (!cacheFile.startsWith(".")) {
if (!cacheFile.startsWith(QLatin1String("."))) {
cacheFiles.append(cachedir.absoluteFilePath(cacheFile));
}
}
......@@ -242,10 +242,10 @@ void Cache::cleanCache(MaxSizePolicy policy)
bool Cache::Private::cleanNotInstalled()
{
try {
SQLiteConnection database(databasedir.absoluteFilePath("local.db"), true);
SQLiteConnection database(databasedir.absoluteFilePath(QStringLiteral("local.db")), true);
foreach (QString const& file, cacheFiles) {
database.bind(":Filename", file.split("/").last());
SQLiteResource res = database.query( Queries::selectPackages("filename", "=", ":Filename") );
database.bind(QStringLiteral(":Filename"), file.split(QStringLiteral("/")).last());
SQLiteResource res = database.query( Queries::selectPackages(QStringLiteral("filename"), QStringLiteral("="), QStringLiteral(":Filename")) );
if (res.getRowsCount() == 0) {
if (!Helpers::removeFile(file)) {
error = QObject::tr("Failed to remove file!");
......@@ -254,7 +254,7 @@ bool Cache::Private::cleanNotInstalled()
}
}
} catch (SQLiteException &exc) {
qWarning() << "Caught an error with" << cachedir.absoluteFilePath("local.db") << ":" << exc.what();
qWarning() << "Caught an error with" << cachedir.absoluteFilePath(QStringLiteral("local.db")) << ":" << exc.what();
return false;
}
return true;
......@@ -297,7 +297,7 @@ bool Cache::Private::cleanAll()
foreach (QString const& file, plainEntryList) {
QString packageName = getPackageName(file);
if (file.startsWith(".") || keepPackages.contains(packageName)) {
if (file.startsWith(QLatin1String(".")) || keepPackages.contains(packageName)) {
continue;
}
......@@ -324,7 +324,7 @@ QString Cache::Private::getPackageName(const QString& filename)
}
pkgname += token;
pkgname += "-";
pkgname += QLatin1String("-");
}
pkgname.resize(pkgname.size() - 1);
......@@ -341,7 +341,7 @@ QString Cache::Private::getPackageVersion(const QString& filename)
}
pkgver += token;
pkgver += "-";
pkgver += QLatin1String("-");
}
pkgver.resize(pkgver.size() - 1);
......
......@@ -84,7 +84,7 @@ Config::Config()
{
Q_ASSERT(!s_globalConfig()->q);
s_globalConfig()->q = this;
setRoot("/");
setRoot(QStringLiteral("/"));
setCachePath(Akabei::DEFAULT_CACHE_DIR.toString());
setDatabasePath(Akabei::DEFAULT_DATABASE_DIR.toString());
}
......
......@@ -45,7 +45,7 @@ void DatabasePrivate::init()
{
try {
qDebug() << "Connect to db" << pathToDb;
dbConnection.connectToDB(pathToDb, !pathToDb.endsWith("local.db"));
dbConnection.connectToDB(pathToDb, !pathToDb.endsWith(QLatin1String("local.db")));
populateGroupCache(); /* populate group cache on startup */
valid = true;
} catch (SQLiteException &ex) {
......@@ -78,15 +78,15 @@ Group* DatabasePrivate::groupFromRow(SQLiteResource& table, int row)
{
using namespace Tables::Groups;
QString name = table.getDataAt(row, "name").toString();
QString name = table.getDataAt(row, QStringLiteral("name")).toString();
// Is our group still not into the pool?
if (!Backend::instance()->d_func()->groupPool->contains(name)) {
// In this case, populate its fields
Group* group = Backend::instance()->d_func()->groupPool->group(name);
group->d_ptr->setDescription(table.getDataAt(row, "description").toString());
group->d_ptr->setIcon(table.getDataAt(row, "icon").toString());
group->d_ptr->setDescription(table.getDataAt(row, QStringLiteral("description")).toString());
group->d_ptr->setIcon(table.getDataAt(row, QStringLiteral("icon")).toString());
return group;
}
......@@ -98,8 +98,8 @@ Package* DatabasePrivate::packageFromRow(SQLiteResource& table, int row)
{
Q_Q(Database);
int id = table.getDataAt(row, "id").toInt();
int installreason = table.getDataAt(row, "installreason").toInt();
int id = table.getDataAt(row, QStringLiteral("id")).toInt();
int installreason = table.getDataAt(row, QStringLiteral("installreason")).toInt();
// Does the cache contain our package?
if (packageCache.contains(id)) {
......@@ -111,73 +111,73 @@ Package* DatabasePrivate::packageFromRow(SQLiteResource& table, int row)
using namespace Tables::Packages;
// We suppose the statement is actually valid. So let's create our package.
Package *package = new Package(q, id, table.getDataAt(row, "name").toString());
Package *package = new Package(q, id, table.getDataAt(row, QStringLiteral("name")).toString());
QString url = table.getDataAt(row, "url").toString();
QString md5 = table.getDataAt(row, "md5sum").toString();
QString screenshotUrl = table.getDataAt(row, "screenshoturl").toString();
QString url = table.getDataAt(row, QStringLiteral("url")).toString();
QString md5 = table.getDataAt(row, QStringLiteral("md5sum")).toString();
QString screenshotUrl = table.getDataAt(row, QStringLiteral("screenshoturl")).toString();
package->d_func()->setArch(table.getDataAt(row, "arch").toString());
package->d_func()->setBuildDate(QDateTime::fromTime_t(table.getDataAt(row, "builddate").toInt()));
package->d_func()->setInstallDate(QDateTime::fromTime_t(table.getDataAt(row, "installdate").toInt()));
package->d_func()->setDescription(table.getDataAt(row, "description").toString());
package->d_func()->setFilename(table.getDataAt(row, "filename").toString());
package->d_func()->setArch(table.getDataAt(row, QStringLiteral("arch")).toString());
package->d_func()->setBuildDate(QDateTime::fromTime_t(table.getDataAt(row, QStringLiteral("builddate")).toInt()));
package->d_func()->setInstallDate(QDateTime::fromTime_t(table.getDataAt(row, QStringLiteral("installdate")).toInt()));
package->d_func()->setDescription(table.getDataAt(row, QStringLiteral("description")).toString());
package->d_func()->setFilename(table.getDataAt(row, QStringLiteral("filename")).toString());
package->d_func()->setMd5sum(md5.toUtf8());
package->d_func()->setPackager(table.getDataAt(row, "packager").toString());
package->d_func()->setSize(table.getDataAt(row, "size").toInt());
package->d_func()->setInstalledSize(table.getDataAt(row, "installedsize").toInt());
package->d_func()->setVersion(Package::Version(table.getDataAt(row, "version").toString().toUtf8()));
package->d_func()->setEpoch(table.getDataAt(row, "epoch").toInt());
if (screenshotUrl != "NULL") {
package->d_func()->setPackager(table.getDataAt(row, QStringLiteral("packager")).toString());
package->d_func()->setSize(table.getDataAt(row, QStringLiteral("size")).toInt());
package->d_func()->setInstalledSize(table.getDataAt(row, QStringLiteral("installedsize")).toInt());
package->d_func()->setVersion(Package::Version(table.getDataAt(row, QStringLiteral("version")).toString().toUtf8()));
package->d_func()->setEpoch(table.getDataAt(row, QStringLiteral("epoch")).toInt());
if (screenshotUrl != QLatin1String("NULL")) {
package->d_func()->setScreenshot(QUrl(screenshotUrl));
}
if (url != "NULL") {
if (url != QLatin1String("NULL")) {
package->d_func()->setUrl(QUrl(url));
}
// Fetch the provided package names
SQLiteResource res = dbConnection.query(QString("SELECT provides FROM provides WHERE package=%1").arg(id));
SQLiteResource res = dbConnection.query(QStringLiteral("SELECT provides FROM provides WHERE package=%1").arg(id));
foreach (const QVariant& v, res.getColumn("provides")) {
package->d_func()->addProvider(v.toString());
}