Commit 3f0d28dc authored by Fabian Kosmale's avatar Fabian Kosmale

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

parent af771237
......@@ -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);
}
This diff is collapsed.
......@@ -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());
}
......
This diff is collapsed.
......@@ -105,17 +105,17 @@ QString Delta::xdeltaApplyCommand(const QString& pathToDest) const
}
QString retstring;
if (d->pathToDelta.endsWith(".gz")) {
retstring = QString("xdelta3 -d -q -R -c -s %1 %2 | gzip -n > %3").arg(
if (d->pathToDelta.endsWith(QLatin1String(".gz"))) {
retstring = QStringLiteral("xdelta3 -d -q -R -c -s %1 %2 | gzip -n > %3").arg(
d->pathToOldFile,
d->pathToDelta,
pathToDest);
} else {
ArchiveHandler handle(d->pathToDelta);
QString deltaPath = Akabei::Config::instance()->rootDir().absoluteFilePath("tmp/" + d->pathToDelta.split('/').last().remove(".tar.xz"));
handle.extract(d->pathToDelta.split('/').last().remove(".tar.xz"), deltaPath, true);
QString deltaPath = Akabei::Config::instance()->rootDir().absoluteFilePath("tmp/" + d->pathToDelta.split('/').last().remove(QStringLiteral(".tar.xz")));
handle.extract(d->pathToDelta.split('/').last().remove(QStringLiteral(".tar.xz")), deltaPath, true);
retstring = QString("xdelta3 -d -q -s %1 %2 %3").arg(
retstring = QStringLiteral("xdelta3 -d -q -s %1 %2 %3").arg(
d->pathToOldFile,
deltaPath,
pathToDest);
......
This diff is collapsed.
......@@ -53,7 +53,7 @@ QString Akabei::Hook::path()
if (d->file)
return d->file->fileName();
d->file = new QTemporaryFile(Config::instance()->rootDir().absoluteFilePath("tmp/akabei_XXXXXX"));
d->file = new QTemporaryFile(Config::instance()->rootDir().absoluteFilePath(QStringLiteral("tmp/akabei_XXXXXX")));
d->file->open();
QTextStream out(d->file);
out << d->content;
......
......@@ -99,9 +99,9 @@ public:
} else {
/* Log through polkit */
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.logging.log")) {
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/logging", "org.chakraproject.akabeicorehelper.logging", QDBusConnection::systemBus());
QDBusMessage mes = iface.call("log", data);
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.logging.log"))) {
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/logging"), QStringLiteral("org.chakraproject.akabeicorehelper.logging"), QDBusConnection::systemBus());
QDBusMessage mes = iface.call(QStringLiteral("log"), data);
if ( !mes.errorMessage().isEmpty() ) {
std::cerr << "Log error: an error occurred while logging via polkit" << std::endl;
......@@ -115,7 +115,7 @@ public:
QString getCurrentDateTime() const
{
return QDateTime::currentDateTime().toString("[dd/MM/yy hh:mm:ss] ");
return QDateTime::currentDateTime().toString(QStringLiteral("[dd/MM/yy hh:mm:ss] "));
}
QString data;
......@@ -145,9 +145,9 @@ void AkabeiLogLine::initialize(bool syslog, const QString& filename)
} else {
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.logging.init")) {
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/logging", "org.chakraproject.akabeicorehelper.logging", QDBusConnection::systemBus());
QDBusMessage mes = iface.call("init", filename);
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.logging.init"))) {
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/logging"), QStringLiteral("org.chakraproject.akabeicorehelper.logging"), QDBusConnection::systemBus());
QDBusMessage mes = iface.call(QStringLiteral("init"), filename);
if (mes.errorMessage().isEmpty()) {
systemInitialized = true;
......
This diff is collapsed.
......@@ -17,112 +17,112 @@ namespace Queries
QString selectGroups(const QString& property, const QString& comparison, const QString& value)
{
return QString("SELECT * FROM groups WHERE %1 %2 \"%3\";").arg(property, comparison, value);
return QStringLiteral("SELECT * FROM groups WHERE %1 %2 \"%3\";").arg(property, comparison, value);
}
QString selectGroupsNameOrDescription(const QString& token, const QString& comparison)
{
return QString("SELECT * FROM groups WHERE name %1 \"%2\" OR description %2 \"%3\";").arg(token, comparison, token);
return QStringLiteral("SELECT * FROM groups WHERE name %1 \"%2\" OR description %2 \"%3\";").arg(token, comparison, token);
}
QString selectPackages(const QString& property, const QString& comparison, const QString& value)
{
return QString("SELECT * FROM packages WHERE %1 %2 \"%3\";").arg(property, comparison, value);
return QStringLiteral("SELECT * FROM packages WHERE %1 %2 \"%3\";").arg(property, comparison, value);
}
QString selectPackagesNameOrDescription(const QString& token, const QString& comparison)
{
return QString("SELECT * FROM packages WHERE name %1 \"%2\" OR description %1 \"%2\";").arg(comparison, token);
return QStringLiteral("SELECT * FROM packages WHERE name %1 \"%2\" OR description %1 \"%2\";").arg(comparison, token);
}
QString selectHooks(const QString& property, const QString& comparison, const QString& value)
{
return QString("SELECT * FROM hooks WHERE %1 %2 \"%3\":").arg(property, comparison, value);
return QStringLiteral("SELECT * FROM hooks WHERE %1 %2 \"%3\":").arg(property, comparison, value);
}
QString selectDeltas(const QString& property, const QString& comparison, const QString& value)
{
return QString("SELECT * FROM deltas WHERE %1 %2 \"%3\";").arg(property, comparison, value);
return QStringLiteral("SELECT * FROM deltas WHERE %1 %2 \"%3\";").arg(property, comparison, value);
}
QString allPackages()
{
return QString("SELECT * FROM packages;");
return QStringLiteral("SELECT * FROM packages;");
}
QString allGroups()
{
return QString("SELECT * FROM groups;");
return QStringLiteral("SELECT * FROM groups;");
}
QString packageProperty(const QString& property, const QString& table, int packageId)
{
QString id = QString::number(packageId);
return QString("SELECT %1 FROM %2 WHERE package=\"%3\";").arg(property, table, id);
return QStringLiteral("SELECT %1 FROM %2 WHERE package=\"%3\";").arg(property, table, id);
}
QString packageHooks(int packageId)
{
QString id = QString::number(packageId);
return QString("SELECT * FROM belongshook JOIN hooks ON package=\"%1\" AND belongshook.hookname=hooks.name;").arg(id);
return QStringLiteral("SELECT * FROM belongshook JOIN hooks ON package=\"%1\" AND belongshook.hookname=hooks.name;").arg(id);
}
QString packagesFromHook(const QString& hook)
{
return QString("SELECT * FROM belongshook JOIN packages ON hookname=\"%1\" AND belongshook.package=packages.id;").arg(hook);
return QStringLiteral("SELECT * FROM belongshook JOIN packages ON hookname=\"%1\" AND belongshook.package=packages.id;").arg(hook);
}
QString packagesInGroup(const QString& group, const QString& token)
{
return QString("SELECT * FROM packages JOIN belongsgroup ON packages.id=belongsgroup.package WHERE belongsgroup.groupname=\"%1\" \
return QStringLiteral("SELECT * FROM packages JOIN belongsgroup ON packages.id=belongsgroup.package WHERE belongsgroup.groupname=\"%1\" \
AND (name LIKE \"%2\" OR description LIKE \"%2\");").arg(group, token);
}
QString belongsGroup(const QString& group, const QString& package)
{
return QString("SELECT * FROM belongsgroup JOIN groups ON groups.name=\"%1\" AND package=\"%2\";").arg(group, package);
return QStringLiteral("SELECT * FROM belongsgroup JOIN groups ON groups.name=\"%1\" AND package=\"%2\";").arg(group, package);
}
QString allPackagesInGroup(const QString& group)
{
return QString("SELECT * FROM packages JOIN belongsgroup ON packages.id=belongsgroup.package \
return QStringLiteral("SELECT * FROM packages JOIN belongsgroup ON packages.id=belongsgroup.package \
WHERE belongsgroup.groupname=\"%1\";").arg(group);
}
QString requiredByPackages(const QString& dependency)
{
return QString("SELECT packages.* FROM depends JOIN packages ON packages.id = depends.package \
return QStringLiteral("SELECT packages.* FROM depends JOIN packages ON packages.id = depends.package \
WHERE depends.dependency REGEXP \"%1\";").arg(dependency);
}
QString packageDependencies(const QString& dependency, const QString& comparison)
{
return QString("SELECT * FROM packages JOIN depends ON packages.id=depends.package WHERE depends.dependency %0 \"%1\";").arg(comparison, dependency);
return QStringLiteral("SELECT * FROM packages JOIN depends ON packages.id=depends.package WHERE depends.dependency %0 \"%1\";").arg(comparison, dependency);
}
QString globalReplaces()
{
return QString("SELECT * FROM replaces JOIN packages ON replaces.package = packages.id");
return QStringLiteral("SELECT * FROM replaces JOIN packages ON replaces.package = packages.id");
}
QString begin()
{
return QString("BEGIN;");
return QStringLiteral("BEGIN;");
}
QString commit()
{
return QString("COMMIT;");
return QStringLiteral("COMMIT;");
}
QString vacuum()
{
return QString("VACUUM;");
return QStringLiteral("VACUUM;");
}
QString rollback()
{
return QString("ROLLBACK;");
return QStringLiteral("ROLLBACK;");
}
}
......
......@@ -402,7 +402,7 @@ void ValidatorWorker::processNextPhase()
// Check if we are breaking dependencies somehow
foreach (const QString &target, targetRemovals) {
QString rT = Helpers::versionedTarget(target).first;
QString sql = Queries::packageDependencies(rT, "LIKE");
QString sql = Queries::packageDependencies(rT, QStringLiteral("LIKE"));
QList<Package*> ret = Backend::instance()->localDatabase()->queryPackages(sql);
// Iterate: we might have found targets that are not the ones we're looking for (due to version handling)
foreach (Package *p, ret) {
......
......@@ -20,9 +20,9 @@ int main(int argc, char *argv[])
void DatabaseBenchmark::benchmark_start()
{
Akabei::Config::instance()->setDatabasePath("/home/lukas/Development/buildroot/databases/");
Akabei::Config::instance()->setRoot("/home/lukas/Development/buildroot/_chroots/master-x32/");
Akabei::Config::instance()->setCachePath("/home/lukas/Development/buildroot/_cache-x32/");
Akabei::Config::instance()->setDatabasePath(QStringLiteral("/home/lukas/Development/buildroot/databases/"));
Akabei::Config::instance()->setRoot(QStringLiteral("/home/lukas/Development/buildroot/_chroots/master-x32/"));
Akabei::Config::instance()->setCachePath(QStringLiteral("/home/lukas/Development/buildroot/_cache-x32/"));
//Akabei::Config::instance()->setDatabases(QStringList() << "test1" << "test2");
......
......@@ -202,7 +202,7 @@ size_t ArchiveHandler::totalEntrySize() const
bool ArchiveHandler::checkPackageValidity()
{
return (entries.find(".PKGINFO") != entries.end());
return (entries.find(QStringLiteral(".PKGINFO")) != entries.end());
}
void ArchiveHandler::handleEntries(Akabei::EntryHandlerFunctor& handler)
......@@ -229,7 +229,7 @@ void ArchiveHandler::handleEntries(Akabei::EntryHandlerFunctor& handler)
QString ArchiveHandler::readTextFile(const QString& textFile)
{
if (!entries.contains(textFile)) {
QString message = "ERROR: no such file in archive: %1";
QString message = QStringLiteral("ERROR: no such file in archive: %1");
throw ArchiveException(message.arg(textFile).toUtf8().data());
}
......@@ -505,7 +505,7 @@ bool InstallFunctor::operator()(const ArchiveEntry& currentEntry)
{
QString entryName = currentEntry.getFileName();
if (entryName == ".INSTALL" || entryName == ".PKGINFO" || entryName == ".MTREE" || entryName == ".Changelog")
if (entryName == QLatin1String(".INSTALL") || entryName == QLatin1String(".PKGINFO") || entryName == QLatin1String(".MTREE") || entryName == QLatin1String(".Changelog"))
return true;
OperationUtils utils;
......@@ -574,7 +574,7 @@ bool ReinstallUpgradeFunctor::operator()(const ArchiveEntry& currentEntry)
{
QString entryName = currentEntry.getFileName();
if (entryName == ".INSTALL" || entryName == ".PKGINFO")
if (entryName == QLatin1String(".INSTALL") || entryName == QLatin1String(".PKGINFO"))
return true;
OperationUtils utils;
......@@ -653,7 +653,7 @@ ExtractAllFunctor::ExtractAllFunctor(QString p, bool ow, Akabei::Operation *call
, pathPrefix(p)
, overwrite(ow)
{
if (!pathPrefix.endsWith("/")) {
if (!pathPrefix.endsWith(QLatin1String("/"))) {
pathPrefix.append("/");
}
}
......
......@@ -32,7 +32,7 @@ public:
handler = new ArchiveHandler(file);
iface = new QDBusInterface("org.chakraproject.akabeicorehelper", "/archive", "org.chakraproject.akabeicorehelper.archive", QDBusConnection::systemBus());
iface = new QDBusInterface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/archive"), QStringLiteral("org.chakraproject.akabeicorehelper.archive"), QDBusConnection::systemBus());
}
~Private() {
delete handler;
......@@ -79,9 +79,9 @@ bool PolKitArchiveHandler::write(const QString& filename, const QHash<QString, Q
return ArchiveHandler::write(filename, files);
}
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.write")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.write"))) {
qDebug() << "Authorization granted";
QDBusInterface iface("org.chakraproject.akabeicorehelper", "/archive", "org.chakraproject.akabeicorehelper.archive", QDBusConnection::systemBus());
QDBusInterface iface(QStringLiteral("org.chakraproject.akabeicorehelper"), QStringLiteral("/archive"), QStringLiteral("org.chakraproject.akabeicorehelper.archive"), QDBusConnection::systemBus());
iface.setProperty("filename", filename);
......@@ -90,7 +90,7 @@ bool PolKitArchiveHandler::write(const QString& filename, const QHash<QString, Q
const auto& k = it.key();
map.insert(k, files[k]);
}
QDBusMessage mes = iface.call("write", map);
QDBusMessage mes = iface.call(QStringLiteral("write"), map);
return !mes.arguments().isEmpty() && mes.arguments().first().toBool();
} else {
qDebug() << "Authorization not granted" << PolkitQt1::Authority::instance()->errorDetails();//TODO:Error handling
......@@ -105,11 +105,11 @@ QStringList PolKitArchiveHandler::getEntries() const
if (!Akabei::Config::instance()->needsPrivileges() || d->readLocally)
return d->handler->getEntries();
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.read")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.read"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("entries");
QDBusMessage mes = d->iface->call(QStringLiteral("entries"));
if (!mes.arguments().isEmpty())
return mes.arguments().first().toStringList();
} else {
......@@ -124,11 +124,11 @@ size_t PolKitArchiveHandler::getEntrySize(QString const& fileName) const
if (!Akabei::Config::instance()->needsPrivileges() || d->readLocally)
return d->handler->getEntrySize(fileName);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.read")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.read"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("entrySize", fileName);
QDBusMessage mes = d->iface->call(QStringLiteral("entrySize"), fileName);
if (!mes.arguments().isEmpty())
return mes.arguments().first().toInt();
} else {
......@@ -144,11 +144,11 @@ size_t PolKitArchiveHandler::totalEntrySize() const
if (!Akabei::Config::instance()->needsPrivileges() || d->readLocally)
return d->handler->totalEntrySize();
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.read")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.read"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("totalEntrySize");
QDBusMessage mes = d->iface->call(QStringLiteral("totalEntrySize"));
if (!mes.arguments().isEmpty())
return mes.arguments().first().toInt();
} else {
......@@ -164,11 +164,11 @@ QString PolKitArchiveHandler::readTextFile(const QString &file)
if (!Akabei::Config::instance()->needsPrivileges() || d->readLocally)
return d->handler->readTextFile(file);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.read")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.read"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("readTextFile", file);
QDBusMessage mes = d->iface->call(QStringLiteral("readTextFile"), file);
if (!mes.arguments().isEmpty())
return mes.arguments().first().toString();
} else {
......@@ -184,11 +184,11 @@ void PolKitArchiveHandler::extract(const QString& source, const QString& destNam
if (!Akabei::Config::instance()->needsPrivileges())
return d->handler->extract(source, destName, overwrite);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.extract"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("extract", source, destName, overwrite);
QDBusMessage mes = d->iface->call(QStringLiteral("extract"), source, destName, overwrite);
} else {
qDebug() << "Authorization not granted" << PolkitQt1::Authority::instance()->errorDetails();
Akabei::ErrorQueue::instance()->appendError(Akabei::Error(Akabei::Error::PermissionError, PolkitQt1::Authority::instance()->errorDetails()));
......@@ -200,11 +200,11 @@ void PolKitArchiveHandler::extract(const ArchiveEntry &entry, const QString& des
if (!Akabei::Config::instance()->needsPrivileges())
return d->handler->extract(entry, destName, overwrite);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.extract"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("extract", entry.getFileName(), destName, overwrite);
QDBusMessage mes = d->iface->call(QStringLiteral("extract"), entry.getFileName(), destName, overwrite);
} else {
qDebug() << "Authorization not granted" << PolkitQt1::Authority::instance()->errorDetails();
Akabei::ErrorQueue::instance()->appendError(Akabei::Error(Akabei::Error::PermissionError, PolkitQt1::Authority::instance()->errorDetails()));
......@@ -216,11 +216,11 @@ void PolKitArchiveHandler::extractAll(const QString& pathPrefix, bool overwrite)
if (!Akabei::Config::instance()->needsPrivileges())
return d->handler->extractAll(pathPrefix, overwrite);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.extract")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.extract"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("extractAll", pathPrefix, overwrite);
QDBusMessage mes = d->iface->call(QStringLiteral("extractAll"), pathPrefix, overwrite);
} else {
qDebug() << "Authorization not granted" << PolkitQt1::Authority::instance()->errorDetails();
Akabei::ErrorQueue::instance()->appendError(Akabei::Error(Akabei::Error::PermissionError, PolkitQt1::Authority::instance()->errorDetails()));
......@@ -232,11 +232,11 @@ QList<QByteArray> PolKitArchiveHandler::md5(const QStringList& files)
if (!Akabei::Config::instance()->needsPrivileges() || d->readLocally)
return d->handler->md5(files);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.read")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.read"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("md5", files);
QDBusMessage mes = d->iface->call(QStringLiteral("md5"), files);
if (!mes.arguments().isEmpty())
return mes.arguments().first().value< QList<QByteArray> >();
} else {
......@@ -252,11 +252,11 @@ QByteArray PolKitArchiveHandler::md5(const QString &file)
return d->handler->md5(file);
if (Akabei::Helpers::checkAuthorizationSync("org.chakraproject.akabeicorehelper.archive.read")) {
if (Akabei::Helpers::checkAuthorizationSync(QStringLiteral("org.chakraproject.akabeicorehelper.archive.read"))) {
qDebug() << "Authorization granted";
d->iface->setProperty("filename", d->filename);
QDBusMessage mes = d->iface->call("md5", file);
QDBusMessage mes = d->iface->call(QStringLiteral("md5"), file);
if (!mes.arguments().isEmpty())
return mes.arguments().first().toByteArray();
} else {
......@@ -271,7 +271,7 @@ bool PolKitArchiveHandler::checkPackageValidity()
if (!Akabei::Config::instance()->needsPrivileges() || d->readLocally)
return d->handler->checkPackageValidity();
return !readTextFile(".PKGINFO").isEmpty();
return !readTextFile(QStringLiteral(".PKGINFO")).isEmpty();
}
Akabei::Error::List PolKitArchiveHandler::errors()
......
......@@ -29,19 +29,19 @@ bool OperationUtils::validatePackage(Akabei::Package *package)
// First, let's check if the archive actually exists and it’s valid.
if (!QFile::exists(package->pathToArchive())) {
// Utter fail.
m_errorMessage = "Archive was not found on disk!";
m_errorMessage = QStringLiteral("Archive was not found on disk!");
return false;
}
// Now let’s check the file integrity (md5 and stuff).
if (!package->checkMD5Sum()) {
m_errorMessage = "MD5Sum of archive not correct!";
m_errorMessage = QStringLiteral("MD5Sum of archive not correct!");
return false;
}
// Ok, now let’s check that we are actually able to load the archive.
if (!package->checkArchiveValidity()) {
m_errorMessage = "Archive is not valid.";
m_errorMessage = QStringLiteral("Archive is not valid.");
return false;
}
......
......@@ -59,7 +59,7 @@ PlainHookOperation *PlainHookOperation::instance()
}
PlainHookOperation::PlainHookOperation()
: Operation("Hooks"),
: Operation(QStringLiteral("Hooks")),
d(new Private(this))
{
Q_ASSERT(!s_globalHookOp()->q);
......@@ -106,14 +106,14 @@ void PlainHookOperation::Private::process()
QFile tmp(hookPath);
tmp.open(QFile::ReadWrite);
tmp.seek(tmp.size());
tmp.write(QString("\n%1\n").arg(it->second).toUtf8());
tmp.write(QStringLiteral("\n%1\n").arg(it->second).toUtf8());
tmp.close();
pro = new ChrootedProcess(q, Config::instance()->root());//The ChrootedProcess deletes itself
q->connect(pro, SIGNAL(errorsOccured(Akabei::Error::List)), SLOT(slotErrors(Akabei::Error::List)), Qt::DirectConnection);
q->connect(pro, SIGNAL(scriptFinished(bool)), SLOT(slotFinished(bool)), Qt::DirectConnection);
q->connect(pro, SIGNAL(addMessage(QString)), SLOT(slotMessage(QString)), Qt::DirectConnection);
pro->run(QString("%1").arg(tmp.fileName()));
pro->run(QStringLiteral("%1").arg(tmp.fileName()));
}
void PlainHookOperation::Private::slotErrors(Akabei::Error::List errors)
......
......@@ -207,17 +207,17 @@ void PlainInstallOperation::validate()
// If it has a scriptlet, we need a new suboperation.
if (d->package->hasScriptlet()) {
// Does it have a pre-install function?
if (d->package->retrieveScriptlet().contains("pre_install")) {
if (d->package->retrieveScriptlet().contains(QStringLiteral("pre_install"))) {
// Ok, it does.
QStringList args;
args << "pre_install";
args << QStringLiteral("pre_install");
setPreOperations(Operation::List() << new PlainScriptletOperation(d->package, args));
}
// Does it have a post-install function?
if (d->package->retrieveScriptlet().contains("post_install")) {
if (d->package->retrieveScriptlet().contains(QStringLiteral("post_install"))) {