Commit 2d67b154 authored by AlmAck's avatar AlmAck
Browse files

Merge branch 'master' of ssh://git.chakraos.org/akabeicore

# Conflicts:
#	lib/operations/akabeipolkitreplaceoperation.cpp
parents 998189d9 55cdf9fe
REVIEWBOARD_URL = "https://chakraos.org/reviewboard"
REPOSITORY = "akabeicore"
BRANCH = "master"
TARGET_GROUPS = "akabei"
cmake_minimum_required(VERSION 3.4.0 FATAL_ERROR)
project(akabeicore)
cmake_minimum_required(VERSION 3.0.0)
set(MAJOR_AKABEI_VERSION 0 CACHE INT "Akabei’s major version number" FORCE)
set(MINOR_AKABEI_VERSION 0 CACHE INT "Akabei’s minor version number" FORCE)
set(PATCH_AKABEI_VERSION 1 CACHE INT "Akabei’s patch version number" FORCE)
set(FIX_AKABEI_VERSION 0 CACHE INT "Akabei’s fix version number" FORCE)
set(AKABEI_VERSION_STRING "${MAJOR_AKABEI_VERSION}.${MINOR_AKABEI_VERSION}.${PATCH_AKABEI_VERSION}.${FIX_AKABEI_VERSION}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
option(BUILD_TESTS "Builds various tests and examples for Akabei" ON)
if(CMAKE_COMPILER_IS_GNUCXX AND BUILD_COVERAGE AND BUILD_TESTS)
include(CodeCoverage)
setup_target_for_coverage(${PROJECT_NAME}_coverage ctest coverage)
SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
endif()
if(BUILD_TESTS)
enable_testing()
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-W -Wall)
add_definitions(-Werror)
# set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Compiles with debugging symbols (Debug mode)
if (CMAKE_COMPILER_IS_GNUCC)
......@@ -23,34 +50,12 @@ add_definitions(#-DQT_NO_CAST_TO_ASCII
-DQT_USE_QSTRINGBUILDER
)
set(MAJOR_AKABEI_VERSION 0 CACHE INT "Akabei’s major version number" FORCE)
set(MINOR_AKABEI_VERSION 0 CACHE INT "Akabei’s minor version number" FORCE)
set(PATCH_AKABEI_VERSION 1 CACHE INT "Akabei’s patch version number" FORCE)
set(FIX_AKABEI_VERSION 0 CACHE INT "Akabei’s fix version number" FORCE)
set(AKABEI_VERSION_STRING "${MAJOR_AKABEI_VERSION}.${MINOR_AKABEI_VERSION}.${PATCH_AKABEI_VERSION}.${FIX_AKABEI_VERSION}")
find_package(Qt5 5.2.0 REQUIRED CONFIG COMPONENTS Core Test Network Concurrent DBus Widgets)
find_package(LibArchive REQUIRED)
find_package(Sqlite REQUIRED)
find_package(PolkitQt5-1 REQUIRED)
add_definitions(${QT_DEFINITIONS} -W -Wall)
add_definitions(-Werror)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(
BEFORE SYSTEM
${QT_INCLUDES}
${LIBARCHIVE_INCLUDE_DIR}
${POLKITQT-1_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/lib
${CMAKE_CURRENT_BINARY_DIR}/tools/polkit-helper
${CMAKE_SOURCE_DIR}/lib
${CMAKE_SOURCE_DIR}/tools/polkit-helper
)
# Define install directories
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/akabei" CACHE "Akabei data installation directory" STRING)
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE "Akabei binary installation directory" STRING)
......@@ -59,7 +64,6 @@ set(INCLUDES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/akabeicore" CACHE "Aka
set(STATE_DIR "/var" CACHE "Directory to store cache data and log files, usually under ${STATE_DIR}/{cache,log,etc...})" STRING)
set(CONFIGURATION_DIR "/etc" CACHE "Directory to store Akabei’s configuration files" STRING)
option(BUILD_TESTS "Builds various tests and examples for Akabei" ON)
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/akabeicoreconfig.h.cmake"
......
# Copyright (c) 2012 - 2015, Lars Bilke
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
#
# 2012-01-31, Lars Bilke
# - Enable Code Coverage
#
# 2013-09-17, Joakim Söderberg
# - Added support for Clang.
# - Some additional usage instructions.
#
# USAGE:
# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here:
# http://stackoverflow.com/a/22404544/80480
#
# 1. Copy this file into your cmake modules path.
#
# 2. Add the following line to your CMakeLists.txt:
# INCLUDE(CodeCoverage)
#
# 3. Set compiler flags to turn off optimization and enable coverage:
# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
#
# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
# which runs your test executable and produces a lcov code coverage report:
# Example:
# SETUP_TARGET_FOR_COVERAGE(
# my_coverage_target # Name for custom target.
# test_driver # Name of the test driver executable that runs the tests.
# # NOTE! This should always have a ZERO as exit code
# # otherwise the coverage generation will not complete.
# coverage # Name of output directory.
# )
#
# 4. Build a Debug build:
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# make
# make my_coverage_target
#
#
# Check prereqs
FIND_PROGRAM( GCOV_PATH gcov )
FIND_PROGRAM( LCOV_PATH lcov )
FIND_PROGRAM( GENHTML_PATH genhtml )
FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
IF(NOT GCOV_PATH)
MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
ENDIF() # NOT GCOV_PATH
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
# Clang version 3.0.0 and greater now supports gcov as well.
MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.")
IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
ENDIF()
ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX
SET(CMAKE_CXX_FLAGS_COVERAGE
"-g -O0 --coverage -fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the C++ compiler during coverage builds."
FORCE )
SET(CMAKE_C_FLAGS_COVERAGE
"-g -O0 --coverage -fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the C compiler during coverage builds."
FORCE )
SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used for linking binaries during coverage builds."
FORCE )
SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
FORCE )
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_COVERAGE
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage"))
MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
# Param _targetname The name of new the custom make target
# Param _testrunner The name of the target which runs the tests.
# MUST return ZERO always, even on errors.
# If not, no coverage report will be created!
# Param _outputname lcov output is generated as _outputname.info
# HTML report is generated in _outputname/index.html
# Optional fourth parameter is passed as arguments to _testrunner
# Pass them in list form, e.g.: "-j;2" for -j 2
FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
IF(NOT LCOV_PATH)
MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
ENDIF() # NOT LCOV_PATH
IF(NOT GENHTML_PATH)
MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
ENDIF() # NOT GENHTML_PATH
# Setup target
ADD_CUSTOM_TARGET(${_targetname}
# Cleanup lcov
${LCOV_PATH} --directory . --zerocounters
# Run tests
COMMAND ${_testrunner} ${ARGV3}
# Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
)
# Show info where to find the report
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
COMMAND ;
COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
)
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
# Param _targetname The name of new the custom make target
# Param _testrunner The name of the target which runs the tests
# Param _outputname cobertura output is generated as _outputname.xml
# Optional fourth parameter is passed as arguments to _testrunner
# Pass them in list form, e.g.: "-j;2" for -j 2
FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
IF(NOT PYTHON_EXECUTABLE)
MESSAGE(FATAL_ERROR "Python not found! Aborting...")
ENDIF() # NOT PYTHON_EXECUTABLE
IF(NOT GCOVR_PATH)
MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
ENDIF() # NOT GCOVR_PATH
ADD_CUSTOM_TARGET(${_targetname}
# Run tests
${_testrunner} ${ARGV3}
# Running gcovr
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running gcovr to produce Cobertura code coverage report."
)
# Show info where to find the report
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
COMMAND ;
COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
)
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
......@@ -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());
}
......
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
PARENT_SCOPE
${CMAKE_CURRENT_BINARY_DIR}
)
set(AKABEI_CORE_SRCS
akabeibackend.cpp
akabeiconfig.cpp
......@@ -94,6 +88,13 @@ operations/akabeioperationutils.h
add_library(akabeicore SHARED ${AKABEI_CORE_SRCS} ${AKABEI_OPERATION_SRCS} ${AKABEI_MISSING_MOCS})
target_include_directories(akabeicore PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/lib
${CMAKE_CURRENT_BINARY_DIR}/tools/polkit-helper
${CMAKE_SOURCE_DIR}/lib
${CMAKE_SOURCE_DIR}/tools/polkit-helper
)
set_target_properties(akabeicore PROPERTIES AUTOMOC TRUE)
set_target_properties(akabeicore PROPERTIES VERSION ${MAJOR_AKABEI_VERSION}.${MINOR_AKABEI_VERSION}.${PATCH_AKABEI_VERSION}
......
......@@ -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);
}
......@@ -85,7 +85,8 @@ struct ConcurrentOrphanQuery
allPackages[ pkg->name() ] = pkg;
}
foreach (Package* pkg, allPackages.values()) {
for (auto it = allPackages.constBegin() , end = allPackages.constEnd(); it != end; ++it) {
auto pkg = it.value();
if (pkg->installReason() == Package::ExplicitlyInstalledReason) {
Package::List stack;
......@@ -170,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";
......@@ -182,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()) {
......@@ -200,7 +201,7 @@ QHash<QString, Database*> BackendPrivate::performInitialization()
void BackendPrivate::addDatabase(const QString &name)
{
if (name == "local") {
if (name == QLatin1String("local")) {
return;
}
......@@ -225,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())));
......@@ -249,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;
}
......@@ -282,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);
......@@ -332,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);
......@@ -342,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;
}
......@@ -371,7 +372,7 @@ void BackendPrivate::packageQueryFinished()
QList< Package* > result;
// TODO: why do we append one by one here?
foreach (QList< Package* > res, future.results()) {
foreach (const QList< Package* >& res, future.results()) {
result += res;
}
......@@ -395,7 +396,7 @@ void BackendPrivate::orphanQueryFinished()
sender()->deleteLater();
QList< Package* > result;
foreach (QList< Package* > res, future.results()) {
foreach (const QList< Package* >& res, future.results()) {
result += res;
}
result.removeAll(nullptr);
......@@ -422,7 +423,7 @@ void BackendPrivate::groupQueryFinished()
* avoid adding duplicates to the final list.
*/
foreach (QList< Group* > groupList, future.results()) {
foreach (const QList< Group* >& groupList, future.results()) {
foreach (Group* g, groupList) {
pool.group( g->name() );
}
......@@ -547,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);
}
......@@ -623,7 +624,7 @@ QUuid Backend::queryGroups(const QString& sql)
auto watcher = new QFutureWatcher< QList< Group* > >();
watcher->setProperty("__Akabei_Query_Uuid", uuid.toString());
connect(watcher, SIGNAL(finished()), d, SLOT(groupQueryFinished()));
connect(watcher, &QFutureWatcherBase::finished, d, &BackendPrivate::groupQueryFinished);
d->queryGroupFuturePool.insert(uuid, watcher);
QFuture< QList< Group* > > future = QtConcurrent::mapped(allDbs, ConcurrentGroupQuery(sql));
......@@ -644,7 +645,7 @@ QUuid Backend::queryPackages(const QString& sql)
auto watcher = new QFutureWatcher< QList< Package* > >();
watcher->setProperty("__Akabei_Query_Uuid", uuid.toString());
connect(watcher, SIGNAL(finished()), d, SLOT(packageQueryFinished()));
connect(watcher, &QFutureWatcherBase::finished, d, &BackendPrivate::packageQueryFinished);
d->queryPackageFuturePool.insert(uuid, watcher);
QFuture< QList< Package* > > future = QtConcurrent::mapped(allDbs, ConcurrentPackageQuery(sql));
......@@ -661,7 +662,7 @@ QUuid Backend::orphanPackages()
auto watcher = new QFutureWatcher< QList< Package* > >();
watcher->setProperty("__Akabei_Query_Uuid", uuid.toString());
connect(watcher, SIGNAL(finished()), d, SLOT(orphanQueryFinished()));
connect(watcher, &QFutureWatcherBase::finished, d, &BackendPrivate::orphanQueryFinished);
d->orphanPackageFuturePool.insert(uuid, watcher);
QFuture< QList< Package* > > future = QtConcurrent::run( ConcurrentOrphanQuery() );
......@@ -671,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
......@@ -681,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(