Commit 2d67b154 authored by Luca Giambonini's avatar Luca Giambonini

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);
}
This diff is collapsed.
......@@ -17,7 +17,7 @@
#include <akabeicore_global.h>
#include "akabeierror.h"
struct QUuid;
class QUuid;
namespace Akabei {
class Delta;
class OperationRunner;
......
......@@ -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));
}
}
......@@ -155,8 +155,8 @@ QString Cache::getPathInCache(const QString &filename) const
* were requested a longer time ago (see the RemoveCriteria enumeration).
*/
struct utimbuf time;
time.modtime = QDateTime::currentDateTime().toTime_t();
time.actime = QDateTime::currentDateTime().toTime_t();
time.modtime = QDateTime::currentDateTimeUtc().toTime_t();
time.actime = QDateTime::currentDateTimeUtc().toTime_t();
std::string tmp = filename.toStdString();
utime(tmp.c_str(), &time);
......@@ -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,20 +105,20 @@ 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(d->pathToOldFile)
.arg(d->pathToDelta)
.arg(pathToDest);
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(d->pathToOldFile)
.arg(deltaPath)
.arg(pathToDest);
retstring = QStringLiteral("xdelta3 -d -q -s %1 %2 %3").arg(
d->pathToOldFile,
deltaPath,
pathToDest);
}
return retstring;
......
......@@ -118,9 +118,11 @@ void ErrorQueue::appendError(const Error& error)
QWriteLocker locker(d->mutex);
d->errorQueue.enqueue(error);
foreach (ErrorHandler* registeredHandler, d->errorSlots.values( error.type() )) {
for (auto it = d->errorSlots.constFind( error.type() ), end = d->errorSlots.constEnd(); it != end && it.key() == error.type(); ++it ) {
ErrorHandler* registeredHandler = it.value();
QMetaObject::invokeMethod(registeredHandler->receiver(), registeredHandler->slot(), Qt::QueuedConnection);
}
}
void ErrorQueue::appendErrors(const Error::List& errors)
......@@ -245,4 +247,4 @@ Error::Type Error::type() const
return d->type;
}
}
\ No newline at end of file
}
......@@ -53,8 +53,8 @@ QList< Akabei::Package* > Group::packages() const
Q_D(const Group);
QReadLocker locker(d->mutex);
Helpers::PackageEventLoop e;
e.connect(Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
&e, SLOT(requestQuit(QUuid,QList<Akabei::Package*>)));
e.connect(Backend::instance(), &Backend::queryPackagesCompleted,
&e, &Helpers::PackageEventLoop::requestQuit);
e.setUuid( Backend::instance()->queryPackages( Queries::allPackagesInGroup(d->name) ) );
e.exec();
return e.result();
......@@ -65,8 +65,8 @@ QList< Package* > Group::search(const QString& token) const
Q_D(const Group);
QReadLocker locker(d->mutex);
Helpers::PackageEventLoop e;
e.connect(Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
&e, SLOT(requestQuit(QUuid,QList<Akabei::Package*>)));
e.connect(Backend::instance(), &Backend::queryPackagesCompleted,
&e, &Helpers::PackageEventLoop::requestQuit);
e.setUuid(Backend::instance()->queryPackages( Queries::packagesInGroup(d->name, token) ));
e.exec();
return e.result();
......
......@@ -8,6 +8,8 @@
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef AKABEIGROUP_P_H
#define AKABEIGROUP_P_H
#include <akabeigroup.h>
#include <QReadWriteLock>
......@@ -39,4 +41,5 @@ class GroupPrivate
friend class Group;
};
}
\ No newline at end of file
}
#endif
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;
......
......@@ -18,24 +18,27 @@
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDebug>
#include <QGlobalStatic>
#include <syslog.h>
#include <iostream>
#include <fstream>
const void* Akabei::endlog = ( void* )-1;
/*
* Holds important configuration through different calls.
*/
namespace {
/* Necessary when polkit isn't involved */
static std::ofstream logStream;
Q_GLOBAL_STATIC(std::ofstream, logStream);
static bool isSyslog( false );
static QString pathToFile;
Q_GLOBAL_STATIC(QString, pathToFile);
/* Whether the init occurred correctly */
static bool systemInitialized( false );
static QString __msg_prefix[] = { "", "Warning: ", "Critical: " };
static QLatin1String __msg_prefix[] = { QLatin1String(""), QLatin1String("Warning: "), QLatin1String("Critical: ") };
static int __msg_priority[] = { LOG_INFO, LOG_WARNING, LOG_CRIT };
/*
......@@ -46,7 +49,7 @@ namespace {
*/
static bool permissionsNeeded()
{
Akabei::Helpers::Permissions access = Akabei::Helpers::permissionsOfPath(pathToFile);
Akabei::Helpers::Permissions access = Akabei::Helpers::permissionsOfPath(*pathToFile);
return (!isSyslog && !access.testFlag(Akabei::Helpers::WritePermission));
}
}
......@@ -87,10 +90,10 @@ public:
#pragma clang diagnostic pop
#endif
} else {
logStream << data.toStdString() << std::endl;
logStream.flush();
*logStream << data.toStdString() << std::endl;
logStream->flush();
if (logStream.bad()) {
if (logStream->bad()) {
qDebug() << "Log error: I/O error while writing";
}
}
......@@ -98,9 +101,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;
......@@ -114,7 +117,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;
......@@ -123,7 +126,7 @@ public:
void AkabeiLogLine::initialize(bool syslog, const QString& filename)
{
pathToFile = filename;
*pathToFile = filename;
isSyslog = syslog;
if ( !permissionsNeeded() ) {
......@@ -132,10 +135,10 @@ void AkabeiLogLine::initialize(bool syslog, const QString& filename)
openlog("akabei", LOG_PID | LOG_CONS, LOG_USER); /* open connection for a generic user service */
systemInitialized = true;
} else {
pathToFile = filename;
logStream.open(filename.toUtf8().constData(), std::ios::app);
*pathToFile = filename;
logStream->open(filename.toUtf8().constData(), std::ios::app);
if (!logStream.is_open()) {
if (!logStream->is_open()) {
std::cerr << "Log error: couldn't open log file \"" << filename.toUtf8().constData() << "\" for writing." << std::endl;
} else {
systemInitialized = true;
......</