Browse Source

Merge branch 'master' into raid-support

raid-support
Andrius Štikonas 3 months ago
parent
commit
b620b0caaf
34 changed files with 283 additions and 221 deletions
  1. +1
    -6
      .reuse/dep5
  2. +19
    -18
      CMakeLists.txt
  3. +0
    -1
      src/CMakeLists.txt
  4. +1
    -4
      src/Messages.sh
  5. +26
    -0
      src/XmlMessages.sh
  6. +1
    -1
      src/backend/corebackend.h
  7. +1
    -1
      src/core/device.h
  8. +21
    -5
      src/core/fstab.cpp
  9. +3
    -0
      src/core/fstab.h
  10. +6
    -4
      src/core/lvmdevice.cpp
  11. +1
    -1
      src/core/lvmdevice.h
  12. +1
    -1
      src/core/operationstack.h
  13. +1
    -1
      src/core/partitionnode.h
  14. +3
    -1
      src/core/partitiontable.cpp
  15. +5
    -3
      src/core/raid/softwareraid.cpp
  16. +4
    -2
      src/core/smartattributeparseddata.cpp
  17. +4
    -3
      src/core/smartdiskinformation.cpp
  18. +3
    -1
      src/core/smartparser.cpp
  19. +3
    -2
      src/core/smartstatus.cpp
  20. +4
    -2
      src/fs/filesystemfactory.cpp
  21. +1
    -1
      src/gui/partwidgetbase.h
  22. +1
    -1
      src/jobs/job.h
  23. +97
    -18
      src/ops/newoperation.cpp
  24. +14
    -46
      src/ops/newoperation.h
  25. +1
    -1
      src/ops/operation.h
  26. +3
    -2
      src/ops/resizevolumegroupoperation.cpp
  27. +4
    -2
      src/plugins/sfdisk/sfdiskbackend.cpp
  28. +1
    -1
      src/plugins/sfdisk/sfdiskdevice.h
  29. +2
    -11
      src/util/CMakeLists.txt
  30. +1
    -1
      src/util/externalcommand.h
  31. +0
    -14
      src/util/org.kde.kpmcore.applicationinterface.conf
  32. +0
    -65
      src/util/org.kde.kpmcore.externalcommand.actions
  33. +49
    -0
      src/util/org.kde.kpmcore.externalcommand.policy
  34. +1
    -1
      src/util/report.h

+ 1
- 6
.reuse/dep5 View File

@ -14,11 +14,6 @@ Copyright: 2018 Andrius Štikonas <andrius@stikonas.eu>
Copyright: 2020 KDE translators
### DBus interfaces
Files: src/util/org.kde.kpmcore.*.conf
Files: src/util/org.kde.kpmcore.helperinterface.conf
License: MIT
Copyright: 2018 Andrius Štikonas <andrius@stikonas.eu>
### KAuth actions
Files: src/util/org.kde.kpmcore.externalcommand.actions
License: CC0-1.0
Copyright: 2018 Andrius Štikonas <andrius@stikonas.eu>

+ 19
- 18
CMakeLists.txt View File

@ -5,30 +5,32 @@
# SPDX-License-Identifier: GPL-3.0-or-later
project(kpmcore)
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# KDE Application Version, managed by release script
set (RELEASE_SERVICE_VERSION_MAJOR "21")
set (RELEASE_SERVICE_VERSION_MINOR "03")
set (RELEASE_SERVICE_VERSION_MICRO "70")
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(kpmcore VERSION ${RELEASE_SERVICE_VERSION})
set(SOVERSION "11")
add_definitions(-D'VERSION="${RELEASE_SERVICE_VERSION}"') #"
set(CMAKE_USE_RELATIVE_PATHS OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
# Dependencies
set(QT_MIN_VERSION "5.10.0")
set(KF5_MIN_VERSION "5.56")
set(QT_MIN_VERSION "5.14.0")
set(KF5_MIN_VERSION "5.73")
set(BLKID_MIN_VERSION "2.33.2")
# Qca-qt5 (tested with botan and ossl backends)
# PolkitQt5-1
# Runtime
# smartmontools 7.0
set(VERSION_MAJOR "4")
set(VERSION_MINOR "2")
set(VERSION_RELEASE "0")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE})
set(SOVERSION "10")
add_definitions(-D'VERSION="${VERSION}"') #"
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
@ -42,7 +44,7 @@ include(GenerateExportHeader)
include(ECMSetupVersion)
include(ECMConfiguredInstall)
ecm_setup_version(${VERSION} VARIABLE_PREFIX KPMCORE
ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX KPMCORE
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpmcore_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPMcoreConfigVersion.cmake"
SOVERSION ${SOVERSION})
@ -56,13 +58,12 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
# Load the frameworks we need
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
Auth
CoreAddons
I18n
WidgetsAddons
)
find_package(Qca-qt5 REQUIRED)
find_package(PolkitQt5-1 REQUIRED)
# use sane compile flags
add_definitions(
@ -107,10 +108,10 @@ install(EXPORT KPMcoreTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KPMc
ki18n_install(po)
set_target_properties( kpmcore
PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION}
PROPERTIES VERSION ${RELEASE_SERVICE_VERSION} SOVERSION ${SOVERSION}
)
message(STATUS "kpmcore ${VERSION} will be built for install into ${CMAKE_INSTALL_PREFIX}")
message(STATUS "kpmcore ${RELEASE_SERVICE_VERSION} will be built for install into ${CMAKE_INSTALL_PREFIX}")
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)


+ 0
- 1
src/CMakeLists.txt View File

@ -33,7 +33,6 @@ target_link_libraries( kpmcore PUBLIC
${BLKID_LIBRARIES}
Qt5::DBus
Qt5::Gui
qca-qt5
KF5::I18n
KF5::CoreAddons
KF5::WidgetsAddons


+ 1
- 4
src/Messages.sh View File

@ -4,7 +4,4 @@
# SPDX-License-Identifier: MIT
$EXTRACTRC `find -name \*.rc` >> rc.cpp || exit 11
$EXTRACTRC `find -name \*.ui` >> rc.cpp || exit 12
$XGETTEXT `find -name \*.cc -o -name \*.cpp -o -name \*.h` rc.cpp -o $podir/kpmcore.pot
rm -f rc.cpp
$XGETTEXT $(find -name \*.cc -o -name \*.cpp -o -name \*.h$) -o $podir/kpmcore.pot

+ 26
- 0
src/XmlMessages.sh View File

@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: MIT
function get_files
{
echo util/org.kde.kpmcore.externalcommand.policy
}
function po_for_file
{
case "$1" in
util/org.kde.kpmcore.externalcommand.policy)
echo kpmcore._policy_.po
;;
esac
}
function tags_for_file
{
case "$1" in
util/org.kde.kpmcore.externalcommand.policy)
echo description
echo message
;;
esac
}

+ 1
- 1
src/backend/corebackend.h View File

@ -47,7 +47,7 @@ class LIBKPMCORE_EXPORT CoreBackend : public QObject
protected:
CoreBackend();
virtual ~CoreBackend();
~CoreBackend() override;
Q_SIGNALS:
/**


+ 1
- 1
src/core/device.h View File

@ -56,7 +56,7 @@ public:
public:
explicit Device(const Device& other);
virtual ~Device();
~Device() override;
virtual bool operator==(const Device& other) const;
virtual bool operator!=(const Device& other) const;


+ 21
- 5
src/core/fstab.cpp View File

@ -72,7 +72,7 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
}
QString comment = line.section( QLatin1Char('#'), 1 );
QStringList splitLine = line.section( QLatin1Char('#'), 0, 0 ).split( QRegularExpression(QStringLiteral("[\\s]+")), QString::SkipEmptyParts );
QStringList splitLine = line.section( QLatin1Char('#'), 0, 0 ).split( QRegularExpression(QStringLiteral("[\\s]+")), Qt::SkipEmptyParts );
// We now split the standard components of /etc/fstab entry:
// (0) path, or UUID, or LABEL, etc,
@ -83,7 +83,7 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
// (5) pass number (optional, defaults to 0), no comment is allowed if omitted,
// (#) comment (optional).
auto fsSpec = splitLine.at(0);
auto mountPoint = splitLine.at(1);
auto mountPoint = unescapeSpaces(splitLine.at(1));
auto fsType = splitLine.at(2);
auto options = splitLine.at(3);
@ -110,6 +110,22 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
return fstabEntries;
}
QString escapeSpaces(const QString& mountPoint)
{
QString tmp = mountPoint;
tmp.replace(QStringLiteral(" "), QStringLiteral("\\040"));
tmp.replace(QStringLiteral("\t"), QStringLiteral("\\011"));
return tmp;
}
QString unescapeSpaces(const QString& mountPoint)
{
QString tmp = mountPoint;
tmp.replace(QStringLiteral("\\040"), QStringLiteral(" "));
tmp.replace(QStringLiteral("\\011"), QStringLiteral("\t"));
return tmp;
}
void FstabEntry::setFsSpec(const QString& s)
{
d->m_fsSpec = s;
@ -208,8 +224,8 @@ static QString findBlkIdDevice(const char *token, const QString& value)
free(c);
}
#else
Q_UNUSED(token);
Q_UNUSED(value);
Q_UNUSED(token)
Q_UNUSED(value)
#endif
return rval;
@ -262,7 +278,7 @@ static void writeEntry(QTextStream& s, const FstabEntry& entry, std::array<unsig
s.setFieldAlignment(QTextStream::AlignLeft);
s.setFieldWidth(columnWidth[0]);
s << entry.fsSpec()
<< qSetFieldWidth(columnWidth[1]) << (entry.mountPoint().isEmpty() ? QStringLiteral("none") : entry.mountPoint())
<< qSetFieldWidth(columnWidth[1]) << (entry.mountPoint().isEmpty() ? QStringLiteral("none") : escapeSpaces(entry.mountPoint()))
<< qSetFieldWidth(columnWidth[2]) << entry.type()
<< qSetFieldWidth(columnWidth[3]) << entry.optionsString() << qSetFieldWidth(0)
<< entry.dumpFreq() << " "


+ 3
- 0
src/core/fstab.h View File

@ -111,6 +111,9 @@ private:
typedef QList<FstabEntry> FstabEntryList;
QString escapeSpaces(const QString& mountPoint);
QString unescapeSpaces(const QString& mountPoint);
LIBKPMCORE_EXPORT FstabEntryList readFstabEntries(const QString& fstabPath = QStringLiteral("/etc/fstab"));
LIBKPMCORE_EXPORT QStringList possibleMountPoints(const QString& deviceNode, const QString& fstabPath = QStringLiteral("/etc/fstab"));
LIBKPMCORE_EXPORT bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filename = QStringLiteral("/etc/fstab"));


+ 6
- 4
src/core/lvmdevice.cpp View File

@ -1,6 +1,6 @@
/*
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
SPDX-FileCopyrightText: 2016-2019 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2016-2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net>
@ -21,6 +21,8 @@
#include "util/globallog.h"
#include "util/report.h"
#include <utility>
#include <QRegularExpression>
#include <QStorageInfo>
#include <QtMath>
@ -214,7 +216,7 @@ void LvmDevice::scanSystemLVM(QList<Device*>& devices)
// Inform LvmDevice about which physical volumes form that particular LvmDevice
for (const auto &d : lvmList)
for (const auto &p : qAsConst(LVM::pvList::list()))
for (const auto &p : std::as_const(LVM::pvList::list()))
if (p.vgName() == d->name())
d->physicalVolumes().append(p.partition());
@ -263,7 +265,7 @@ const QStringList LvmDevice::getVGs()
QStringList vgList;
QString output = getField(QStringLiteral("vg_name"));
if (!output.isEmpty()) {
const QStringList vgNameList = output.split(QLatin1Char('\n'), QString::SkipEmptyParts);
const QStringList vgNameList = output.split(QLatin1Char('\n'), Qt::SkipEmptyParts);
for (const auto &vgName : vgNameList) {
vgList.append(vgName.trimmed());
}
@ -277,7 +279,7 @@ const QStringList LvmDevice::getLVs(const QString& vgName)
QString cmdOutput = getField(QStringLiteral("lv_path"), vgName);
if (cmdOutput.size()) {
const QStringList tempPathList = cmdOutput.split(QLatin1Char('\n'), QString::SkipEmptyParts);
const QStringList tempPathList = cmdOutput.split(QLatin1Char('\n'), Qt::SkipEmptyParts);
for (const auto &lvPath : tempPathList) {
lvPathList.append(lvPath.trimmed());
}


+ 1
- 1
src/core/lvmdevice.h View File

@ -40,7 +40,7 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
public:
explicit LvmDevice(const QString& name, const QString& iconName = QString());
~LvmDevice();
~LvmDevice() override;
public:
const QStringList deviceNodes() const override;


+ 1
- 1
src/core/operationstack.h View File

@ -45,7 +45,7 @@ public:
public:
explicit OperationStack(QObject* parent = nullptr);
~OperationStack();
~OperationStack() override;
Q_SIGNALS:
void operationsChanged();


+ 1
- 1
src/core/partitionnode.h View File

@ -33,7 +33,7 @@ public:
protected:
PartitionNode() {}
virtual ~PartitionNode() {}
~PartitionNode() override {}
public:
virtual bool insert(Partition* partNew);


+ 3
- 1
src/core/partitiontable.cpp View File

@ -23,6 +23,8 @@
#include "util/globallog.h"
#include <utility>
#include <KLocalizedString>
#include <QDebug>
@ -592,7 +594,7 @@ QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable)
std::sort(partitions.begin(), partitions.end(), [](const Partition* p1, const Partition* p2) { return p1->number() < p2->number(); });
for (const auto &p : qAsConst(partitions))
for (const auto &p : std::as_const(partitions))
stream << *p;
return stream;


+ 5
- 3
src/core/raid/softwareraid.cpp View File

@ -15,6 +15,8 @@
#include "ops/createpartitiontableoperation.h"
#include "util/externalcommand.h"
#include <utility>
#include <KLocalizedString>
#include <QFile>
#include <QRegularExpression>
@ -206,7 +208,7 @@ void SoftwareRAID::scanSoftwareRAID(QList<Device*>& devices)
d->setPartitionNodes(partitionNodes);
for (const Device* dev : qAsConst(devices)) {
for (const Device* dev : std::as_const(devices)) {
if (dev->partitionTable()) {
for (const Partition* p : dev->partitionTable()->children())
if (getRaidArrayName(p->deviceNode()) == d->deviceNode())
@ -234,7 +236,7 @@ void SoftwareRAID::scanSoftwareRAID(QList<Device*>& devices)
}
}
for (const QString& name : qAsConst(availableInConf)) {
for (const QString& name : std::as_const(availableInConf)) {
SoftwareRAID *raidDevice = new SoftwareRAID(name, SoftwareRAID::Status::Inactive);
devices << raidDevice;
}
@ -386,7 +388,7 @@ bool SoftwareRAID::createSoftwareRAID(Report &report,
QStringLiteral("--chunk=") + QString::number(chunkSize),
QStringLiteral("--raid-devices=") + QString::number(devicePathList.size()) };
for (const QString &p : qAsConst(devicePathList)) {
for (const QString &p : std::as_const(devicePathList)) {
eraseDeviceMDSuperblock(p);
args << p;


+ 4
- 2
src/core/smartattributeparseddata.cpp View File

@ -1,7 +1,7 @@
/*
SPDX-FileCopyrightText: 2008 Lennart Poettering
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
SPDX-FileCopyrightText: 2018-2019 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2018-2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-3.0-or-later
*/
@ -9,6 +9,8 @@
#include "smartattributeparseddata.h"
#include "core/smartdiskinformation.h"
#include <utility>
#include <QJsonObject>
#include <QMap>
#include <QRegularExpression>
@ -615,7 +617,7 @@ static SmartQuirk getQuirk(QString model, QString firmware)
QRegularExpression modelRegex;
QRegularExpression firmwareRegex;
for (const SmartAttributeParsedData::SmartQuirkDataBase &item : qAsConst(db)) {
for (const SmartAttributeParsedData::SmartQuirkDataBase &item : std::as_const(db)) {
if (!item.model.isEmpty()) {
modelRegex.setPattern(item.model);
QRegularExpressionMatch match = modelRegex.match(model);


+ 4
- 3
src/core/smartdiskinformation.cpp View File

@ -1,6 +1,6 @@
/*
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
SPDX-FileCopyrightText: 2018-2019 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2018-2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-3.0-or-later
*/
@ -9,6 +9,7 @@
#include "core/smartattributeparseddata.h"
#include <memory>
#include <utility>
static quint64 u64log2(quint64 n);
@ -145,7 +146,7 @@ bool SmartDiskInformation::updatePowerCycle()
/** Validate disk attributes status */
void SmartDiskInformation::validateBadAttributes()
{
for (const SmartAttributeParsedData &attribute : qAsConst(m_Attributes)) {
for (const SmartAttributeParsedData &attribute : std::as_const(m_Attributes)) {
if (attribute.prefailure()) {
if (attribute.goodNowValid() && !attribute.goodNow())
m_BadAttributeNow = true;
@ -161,7 +162,7 @@ void SmartDiskInformation::validateBadAttributes()
SmartAttributeParsedData *SmartDiskInformation::findAttribute(quint32 id)
{
SmartAttributeParsedData *attr = nullptr;
for (const SmartAttributeParsedData &attribute : qAsConst(m_Attributes)) {
for (const SmartAttributeParsedData &attribute : std::as_const(m_Attributes)) {
if (id == attribute.id()) {
attr = new SmartAttributeParsedData(attribute);
break;


+ 3
- 1
src/core/smartparser.cpp View File

@ -1,5 +1,6 @@
/*
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-3.0-or-later
*/
@ -12,6 +13,7 @@
#include "util/externalcommand.h"
#include <errno.h>
#include <utility>
#include <QDebug>
#include <QJsonArray>
@ -147,7 +149,7 @@ void SmartParser::loadAttributes()
return;
}
for (const QJsonValue &value : qAsConst(attributeArray)) {
for (const QJsonValue &value : std::as_const(attributeArray)) {
SmartAttributeParsedData parsedObject(m_DiskInformation, value.toObject());
m_DiskInformation->addAttribute(parsedObject);
}


+ 3
- 2
src/core/smartstatus.cpp View File

@ -1,7 +1,7 @@
/*
SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de>
SPDX-FileCopyrightText: 2010 Yuri Chornoivan <yurchor@ukr.net>
SPDX-FileCopyrightText: 2014-2019 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
SPDX-FileCopyrightText: 2019 Shubham Jangra <aryan100jangid@gmail.com>
@ -22,6 +22,7 @@
#include <QStringList>
#include <errno.h>
#include <utility>
SmartStatus::SmartStatus(const QString &device_path) :
m_DevicePath(device_path),
@ -144,7 +145,7 @@ void SmartStatus::addAttributes(QList<SmartAttributeParsedData> attr)
{
m_Attributes.clear();
for (const SmartAttributeParsedData &at : qAsConst(attr)) {
for (const SmartAttributeParsedData &at : std::as_const(attr)) {
SmartAttribute sm(at);
m_Attributes.append(sm);
}


+ 4
- 2
src/fs/filesystemfactory.cpp View File

@ -1,6 +1,6 @@
/*
SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
SPDX-FileCopyrightText: 2012-2019 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2012-2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
SPDX-FileCopyrightText: 2017 Pali Rohár <pali.rohar@gmail.com>
SPDX-FileCopyrightText: 2019 Shubham Jangra <aryan100jangid@gmail.com>
@ -10,6 +10,8 @@
SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <utility>
#include "fs/filesystemfactory.h"
#include "fs/filesystem.h"
@ -92,7 +94,7 @@ void FileSystemFactory::init()
fileSystems.insert(FileSystem::Type::Xfs, new FS::xfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Zfs, new FS::zfs(-1, -1, -1, QString()));
for (const auto &fs : qAsConst(fileSystems))
for (const auto &fs : std::as_const(fileSystems))
fs->init();
qDeleteAll(m_FileSystems);


+ 1
- 1
src/gui/partwidgetbase.h View File

@ -33,7 +33,7 @@ class LIBKPMCORE_EXPORT PartWidgetBase : public QWidget
protected:
PartWidgetBase(QWidget* parent) : QWidget(parent) {}
virtual ~PartWidgetBase() {}
~PartWidgetBase() override {}
public:
virtual qint32 borderWidth() const {


+ 1
- 1
src/jobs/job.h View File

@ -49,7 +49,7 @@ protected:
Job();
public:
virtual ~Job() {}
~Job() override {}
Q_SIGNALS:
void started();


+ 97
- 18
src/ops/newoperation.cpp View File

@ -31,37 +31,56 @@
#include <KLocalizedString>
struct NewOperationPrivate
{
NewOperationPrivate(Device& d, Partition* p) :
m_TargetDevice(d),
m_NewPartition(p),
m_CreatePartitionJob(new CreatePartitionJob(d, *p)),
m_SetPartitionLabelJob(nullptr),
m_SetPartitionUUIDJob(nullptr),
m_SetPartitionAttributesJob(nullptr),
m_CreateFileSystemJob(nullptr),
m_SetPartFlagsJob(nullptr),
m_SetFileSystemLabelJob(nullptr),
m_CheckFileSystemJob(nullptr)
{
}
Device& m_TargetDevice;
Partition* m_NewPartition;
CreatePartitionJob* m_CreatePartitionJob;
SetPartitionLabelJob* m_SetPartitionLabelJob;
SetPartitionUUIDJob* m_SetPartitionUUIDJob;
SetPartitionAttributesJob* m_SetPartitionAttributesJob;
CreateFileSystemJob* m_CreateFileSystemJob;
SetPartFlagsJob* m_SetPartFlagsJob;
SetFileSystemLabelJob* m_SetFileSystemLabelJob;
CheckFileSystemJob* m_CheckFileSystemJob;
};
/** Creates a new NewOperation.
@param d the Device to create a new Partition on
@param p pointer to the new Partition to create. May not be nullptr.
*/
NewOperation::NewOperation(Device& d, Partition* p) :
Operation(),
m_TargetDevice(d),
m_NewPartition(p),
m_CreatePartitionJob(new CreatePartitionJob(targetDevice(), newPartition())),
m_SetPartitionLabelJob(nullptr),
m_SetPartitionUUIDJob(nullptr),
m_SetPartitionAttributesJob(nullptr),
m_CreateFileSystemJob(nullptr),
m_SetPartFlagsJob(nullptr),
m_SetFileSystemLabelJob(nullptr),
m_CheckFileSystemJob(nullptr)
d_ptr(std::make_unique<NewOperationPrivate>(d, p))
{
addJob(createPartitionJob());
if (!p->label().isEmpty()) {
m_SetPartitionLabelJob = new SetPartitionLabelJob(targetDevice(), newPartition(), p->label());
d_ptr->m_SetPartitionLabelJob = new SetPartitionLabelJob(targetDevice(), newPartition(), p->label());
addJob(setPartitionLabelJob());
}
if (!p->uuid().isEmpty()) {
m_SetPartitionUUIDJob = new SetPartitionUUIDJob(targetDevice(), newPartition(), p->uuid());
d_ptr->m_SetPartitionUUIDJob = new SetPartitionUUIDJob(targetDevice(), newPartition(), p->uuid());
addJob(setPartitionUUIDJob());
}
if (p->attributes()) {
m_SetPartitionAttributesJob = new SetPartitionAttributesJob(targetDevice(), newPartition(), p->attributes());
d_ptr->m_SetPartitionAttributesJob = new SetPartitionAttributesJob(targetDevice(), newPartition(), p->attributes());
addJob(setPartitionAttributesJob());
}
@ -74,18 +93,18 @@ NewOperation::NewOperation(Device& d, Partition* p) :
// label. The operation stack will merge these operations with this one here
// and if the jobs don't exist things will break.
m_CreateFileSystemJob = new CreateFileSystemJob(targetDevice(), newPartition(), fs.label());
d_ptr->m_CreateFileSystemJob = new CreateFileSystemJob(targetDevice(), newPartition(), fs.label());
addJob(createFileSystemJob());
if (fs.type() == FileSystem::Type::Lvm2_PV) {
m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::Flag::Lvm);
d_ptr->m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::Flag::Lvm);
addJob(setPartFlagsJob());
}
m_SetFileSystemLabelJob = new SetFileSystemLabelJob(newPartition(), fs.label());
d_ptr->m_SetFileSystemLabelJob = new SetFileSystemLabelJob(newPartition(), fs.label());
addJob(setLabelJob());
m_CheckFileSystemJob = new CheckFileSystemJob(newPartition());
d_ptr->m_CheckFileSystemJob = new CheckFileSystemJob(newPartition());
addJob(checkJob());
}
}
@ -93,7 +112,67 @@ NewOperation::NewOperation(Device& d, Partition* p) :
NewOperation::~NewOperation()
{
if (status() == StatusPending)
delete m_NewPartition;
delete d_ptr->m_NewPartition;
}
Partition& NewOperation::newPartition()
{
return *d_ptr->m_NewPartition;
}
const Partition& NewOperation::newPartition() const
{
return *d_ptr->m_NewPartition;
}
Device& NewOperation::targetDevice()
{
return d_ptr->m_TargetDevice;
}
const Device& NewOperation::targetDevice() const
{
return d_ptr->m_TargetDevice;
}
CreatePartitionJob* NewOperation::createPartitionJob()
{
return d_ptr->m_CreatePartitionJob;
}
SetPartitionLabelJob* NewOperation::setPartitionLabelJob()
{
return d_ptr->m_SetPartitionLabelJob;
}
SetPartitionUUIDJob* NewOperation::setPartitionUUIDJob()
{
return d_ptr->m_SetPartitionUUIDJob;
}
SetPartitionAttributesJob* NewOperation::setPartitionAttributesJob()
{
return d_ptr->m_SetPartitionAttributesJob;
}
CreateFileSystemJob* NewOperation::createFileSystemJob()
{
return d_ptr->m_CreateFileSystemJob;
}
SetPartFlagsJob* NewOperation::setPartFlagsJob()
{
return d_ptr->m_SetPartFlagsJob;
}
SetFileSystemLabelJob* NewOperation::setLabelJob()
{
return d_ptr->m_SetFileSystemLabelJob;
}
CheckFileSystemJob* NewOperation::checkJob()
{
return d_ptr->m_CheckFileSystemJob;
}
bool NewOperation::targets(const Device& d) const


+ 14
- 46
src/ops/newoperation.h View File

@ -17,6 +17,7 @@
#include <QString>
struct NewOperationPrivate;
class Device;
class OperationStack;
@ -60,56 +61,23 @@ public:
static Partition* createNew(const Partition& cloneFrom, FileSystem::Type type);
protected:
Partition& newPartition() {
return *m_NewPartition;
}
const Partition& newPartition() const {
return *m_NewPartition;
}
Partition& newPartition();
const Partition& newPartition() const;
Device& targetDevice() {
return m_TargetDevice;
}
const Device& targetDevice() const {
return m_TargetDevice;
}
Device& targetDevice();
const Device& targetDevice() const;
CreatePartitionJob* createPartitionJob() {
return m_CreatePartitionJob;
}
SetPartitionLabelJob* setPartitionLabelJob() {
return m_SetPartitionLabelJob;
}
SetPartitionUUIDJob* setPartitionUUIDJob() {
return m_SetPartitionUUIDJob;
}
SetPartitionAttributesJob* setPartitionAttributesJob() {
return m_SetPartitionAttributesJob;
}
CreateFileSystemJob* createFileSystemJob() {
return m_CreateFileSystemJob;
}
SetPartFlagsJob* setPartFlagsJob() {
return m_SetPartFlagsJob;
}
SetFileSystemLabelJob* setLabelJob() {
return m_SetFileSystemLabelJob;
}
CheckFileSystemJob* checkJob() {
return m_CheckFileSystemJob;
}
CreatePartitionJob* createPartitionJob();
SetPartitionLabelJob* setPartitionLabelJob();
SetPartitionUUIDJob* setPartitionUUIDJob();
SetPartitionAttributesJob* setPartitionAttributesJob();
CreateFileSystemJob* createFileSystemJob();
SetPartFlagsJob* setPartFlagsJob();
SetFileSystemLabelJob* setLabelJob();
CheckFileSystemJob* checkJob();
private:
Device& m_TargetDevice;
Partition* m_NewPartition;
CreatePartitionJob* m_CreatePartitionJob;
SetPartitionLabelJob* m_SetPartitionLabelJob;
SetPartitionUUIDJob* m_SetPartitionUUIDJob;
SetPartitionAttributesJob* m_SetPartitionAttributesJob;
CreateFileSystemJob* m_CreateFileSystemJob;
SetPartFlagsJob* m_SetPartFlagsJob;
SetFileSystemLabelJob* m_SetFileSystemLabelJob;
CheckFileSystemJob* m_CheckFileSystemJob;
std::unique_ptr<NewOperationPrivate> d_ptr;
};
#endif

+ 1
- 1
src/ops/operation.h View File

@ -85,7 +85,7 @@ public:
protected:
Operation();
virtual ~Operation();
~Operation() override;
Q_SIGNALS:
void progress(int);


+ 3
- 2
src/ops/resizevolumegroupoperation.cpp View File

@ -1,6 +1,6 @@
/*
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2016-2020 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-3.0-or-later
*/
@ -14,7 +14,8 @@
#include "jobs/movephysicalvolumejob.h"
#include "util/helpers.h"
#include <QDebug>
#include <utility>
#include <QString>
#include <KLocalizedString>


+ 4
- 2
src/plugins/sfdisk/sfdiskbackend.cpp View File

@ -31,6 +31,8 @@
#include "util/externalcommand.h"
#include "util/helpers.h"
#include <utility>
#include <QDataStream>
#include <QDebug>
#include <QFile>
@ -278,7 +280,7 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
{
QList<Device *> availableDevices = scanDevices();
for (Device *device : qAsConst(availableDevices))
for (Device *device : std::as_const(availableDevices))
if (device && device->deviceNode() == deviceNode)
return device;
}
@ -340,7 +342,7 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit
if (d.partitionTable()->isSectorBased(d))
d.partitionTable()->setType(d, PartitionTable::msdos_sectorbased);
for (const Partition *part : qAsConst(partitions))
for (const Partition *part : std::as_const(partitions))
PartitionAlignment::isAligned(d, *part);
}


+ 1
- 1
src/plugins/sfdisk/sfdiskdevice.h View File

@ -20,7 +20,7 @@ class CoreBackendPartitionTable;
class SfdiskDevice : public CoreBackendDevice
{
Q_DISABLE_COPY(SfdiskDevice);
Q_DISABLE_COPY(SfdiskDevice)
public:
explicit SfdiskDevice(const Device& d);


+ 2
- 11
src/util/CMakeLists.txt View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2008,2012 Volker Lanz <vl@fidra.de>
# SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk>
# SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
# SPDX-FileCopyrightText: 2015 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2015-2020 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <huzaifafaruqui@gmail.com>
# SPDX-FileCopyrightText: 2019 Albert Astals Cid <aacid@kde.org>
# SPDX-FileCopyrightText: 2019 Antonio Rojas <arojas@archlinux.org>
@ -9,7 +9,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
set(application_interface_xml org.kde.kpmcore.applicationinterface.xml)
set(helper_interface_xml org.kde.kpmcore.helperinterface.xml)
qt5_generate_dbus_interface(
@ -24,10 +23,6 @@ qt5_generate_dbus_interface(
OPTIONS -a
)
find_package(PolkitQt5-1 REQUIRED)
qt5_add_dbus_interface(ApplicationInterface_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${application_interface_xml} externalcommand_interface)
qt5_add_dbus_interface(HelperInterface_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${helper_interface_xml} externalcommandhelper_interface)
set(UTIL_SRC
@ -51,7 +46,6 @@ set(UTIL_LIB_HDRS
)
add_executable(kpmcore_externalcommand
${ApplicationInterface_SRCS}
util/externalcommandhelper.cpp
)
@ -64,10 +58,8 @@ add_definitions(
)
target_link_libraries(kpmcore_externalcommand
qca-qt5
Qt5::Core
Qt5::DBus
KF5::AuthCore
KF5::I18n
PolkitQt5-1::Core
)
@ -75,9 +67,8 @@ target_link_libraries(kpmcore_externalcommand
install(TARGETS kpmcore_mdadmupdateconf DESTINATION ${LIBEXEC_INSTALL_DIR})
install(TARGETS kpmcore_externalcommand DESTINATION ${KDE_INSTALL_LIBEXECDIR})
install( FILES util/org.kde.kpmcore.helperinterface.conf DESTINATION ${KDE_INSTALL_DBUSDIR}/system.d )
install( FILES util/org.kde.kpmcore.applicationinterface.conf DESTINATION ${KDE_INSTALL_DBUSDIR}/system.d )
kauth_install_actions(org.kde.kpmcore.externalcommand util/org.kde.kpmcore.externalcommand.actions)
install( FILES util/org.kde.kpmcore.externalcommand.policy DESTINATION ${POLKITQT-1_POLICY_FILES_INSTALL_DIR})
ecm_install_configured_files(
INPUT util/org.kde.kpmcore.helperinterface.service.in
DESTINATION ${KDE_INSTALL_DBUSDIR}/system-services


+ 1
- 1
src/util/externalcommand.h View File

@ -50,7 +50,7 @@ public:
explicit ExternalCommand(const QString& cmd = QString(), const QStringList& args = QStringList(), const QProcess::ProcessChannelMode processChannelMode = QProcess::MergedChannels);
explicit ExternalCommand(Report& report, const QString& cmd = QString(), const QStringList& args = QStringList(), const QProcess::ProcessChannelMode processChannelMode = QProcess::MergedChannels);
~ExternalCommand();
~ExternalCommand() override;
public:
bool copyBlocks(const CopySource& source, CopyTarget& target);


+ 0
- 14
src/util/org.kde.kpmcore.applicationinterface.conf View File

@ -1,14 +0,0 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<allow own="org.kde.kpmcore.applicationinterface"/>
</policy>
<policy user="root">
<allow send_destination="org.kde.kpmcore.applicationinterface"
send_interface="org.kde.kpmcore.applicationinterface"/>
</policy>
</busconfig>

+ 0
- 65
src/util/org.kde.kpmcore.externalcommand.actions View File

@ -1,65 +0,0 @@
[Domain]
Icon=partitionmanager
[org.kde.kpmcore.externalcommand.init]
Name=Start external command daemon
Name[ast]=Aniciu del degorriu de comandos esternos
Name[ca]=Inicia el dimoni d'ordres externes
Name[ca@valencia]=Inicia el dimoni d'ordres externes
Name[cs]=Spustit démona externích příkazů
Name[da]=Start ekstern kommando-dæmon
Name[de]=Externen Befehlsdienst starten
Name[el]=Εκκίνηση διεργασίας με εξωτερική εντολή
Name[en_GB]=Start external command daemon
Name[es]=Iniciar el demonio de órdenes externas
Name[et]=Välise käsu deemoni käivitamine
Name[eu]=Abiarazi kanpoko komandoen daimona
Name[fi]=Käynnistä ulkoinen komentopalvelu
Name[fr]=Lancer le démon de la commande externe
Name[gl]=Iniciar o servizo de orde externa
Name[it]=Avvia demone per comando esterno
Name[ko]=외부 명령 데몬 시작
Name[lt]=Paleisti išorinių komandų tarnybą
Name[nl]=Start externe opdrachtdaemon
Name[pl]=Rozpocznij usługę zewnętrznego polecenia
Name[pt]=Iniciar o servidor de comandos externos
Name[pt_BR]=Iniciar comando externo do daemon
Name[sk]=Spustiť externé démony príkazov
Name[sl]=Zaženite demon za zunanje ukaze
Name[sv]=Starta extern kommandodemon
Name[uk]=Запуск фонової служби зовнішньої команди
Name[x-test]=xxStart external command daemonxx
Name[zh_TW]=啟動外部指令守護程式
Description=Administrative privileges are required to manage disks
Description[ast]=Ríquense los privilexos alministrativos pa xestionar discos
Description[ca]=Es requereixen privilegis d'administrador per a gestionar els discs
Description[ca@valencia]=Es requereixen privilegis d'administrador per a gestionar els discs
Description[cs]=Pro správu disků jsou potřeba práva administrátora
Description[da]=Der kræves administrative rettigheder for at håndtere diske
Description[de]=Systemverwalterrechte sind zur Verwaltung von Festplatten erforderlich
Description[el]=Απαιτούνται δικαιώματα διαχειριστή για τη διαχείριση δίσκων
Description[en_GB]=Administrative privileges are required to manage disks
Description[es]=Se necesitan permisos de administrador para gestionar discos
Description[et]=Ketaste haldamiseks on tarvis administraatori õigusi
Description[eu]=Administrazio pribilegioak behar dira diskoak kudeatzeko
Description[fi]=Levyjen hallinta vaatii pääkäyttäjäoikeuksia
Description[fr]=Vous devez disposer des privilèges d'administrateur pour gérer les disques
Description[gl]=Requírense privilexios de administración para xestionar discos.
Description[it]=Per gestire il disco sono richiesti privilegi di amministratore
Description[ja]=ディスクを管理するには管理者権限が必要です
Description[ko]=디스크를 관리하려면 권한이 필요함
Description[lt]=Diskų tvarkymui reikalingos administratoriaus teisės
Description[nl]=Er zijn administratieve rechten vereist om schijven te beheren
Description[pl]=Do zarządzania dyskami wymagane są uprawnienia administratora
Description[pt]=São necessários privilégios de administrador para gerir os discos
Description[pt_BR]=São necessários privilégios administrativos para gerenciar discos
Description[ru]=Для управления дисками требуются права администратора
Description[sk]=Na správu diskov sa vyžadujú práva správcu
Description[sl]=Za upravljanje diskov so potrebne pravice upravljavca računalnika
Description[sv]=Administratörsprivilegier krävs för att hantera diskar
Description[uk]=Для керування дисками потрібні права доступу адміністратора (root)
Description[x-test]=xxAdministrative privileges are required to manage disksxx
Description[zh_CN]=管理磁盘需要管理权限
Description[zh_TW]=管理硬碟需要管理員權限
Policy=auth_admin
Persistence=session

+ 49
- 0
src/util/org.kde.kpmcore.externalcommand.policy View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: none
SPDX-License-Identifier: CC0-1.0
-->
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<icon_name>partitionmanager</icon_name>
<action id="org.kde.kpmcore.externalcommand.init" >
<description>Start external command daemon</description>
<description xml:lang="ast">Aniciu del degorriu de comandos esternos</description>
<description xml:lang="ca">Inicia el dimoni d'ordres externes</description>
<description xml:lang="ca@valencia">Inicia el dimoni d'ordres externes</description>
<description xml:lang="el">Εκκίνηση διεργασίας με εξωτερική εντολή</description>
<description xml:lang="en_GB">Start external command daemon</description>
<description xml:lang="es">Iniciar el demonio de órdenes externas</description>
<description xml:lang="fr">Lancer le démon externe de commandes</description>
<description xml:lang="it">Avvia demone per comando esterno</description>
<description xml:lang="lt">Paleisti išorinių komandų tarnybą</description>
<description xml:lang="nl">Start externe opdrachtdaemon</description>
<description xml:lang="pt">Iniciar o servidor de comandos externos</description>
<description xml:lang="pt_BR">Iniciar comando externo do daemon</description>
<description xml:lang="sl">Zaženi demon za zunanje ukaze</description>
<description xml:lang="sv">Starta extern kommandodemon</description>
<description xml:lang="uk">Запуск фонової служби зовнішньої команди</description>
<message>Administrative privileges are required to manage disks</message>
<message xml:lang="ast">Ríquense los privilexos alministrativos pa xestionar discos</message>
<message xml:lang="ca">Es requereixen privilegis d'administrador per a gestionar els discs</message>
<message xml:lang="ca@valencia">Es requereixen privilegis d'administrador per a gestionar els discs</message>
<message xml:lang="el">Απαιτούνται δικαιώματα διαχειριστή για τη διαχείριση των δίσκων</message>
<message xml:lang="en_GB">Administrative privileges are required to manage disks</message>
<message xml:lang="es">Se necesitan permisos de administrador para gestionar discos</message>
<message xml:lang="fr">Vous devez disposer des privilèges d'administrateur pour gérer les disques.</message>
<message xml:lang="it">Per gestire il disco sono richiesti privilegi amministrativi</message>
<message xml:lang="lt">Diskų tvarkymui reikalingos administratoriaus teisės</message>
<message xml:lang="nl">Er zijn administratieve rechten vereist om schijven te beheren</message>
<message xml:lang="pt">São necessários privilégios de administração para gerir os discos</message>
<message xml:lang="pt_BR">São necessários privilégios administrativos para gerenciar discos</message>
<message xml:lang="sl">Za upravljanje diskov so potrebne pravice upravljavca računalnika</message>
<message xml:lang="sv">Administratörsprivilegier krävs för att hantera diskar</message>
<message xml:lang="uk">Для керування дисками потрібні права доступу адміністратора (root)</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
</policyconfig>

+ 1
- 1
src/util/report.h View File

@ -36,7 +36,7 @@ class LIBKPMCORE_EXPORT Report : public QObject
public:
explicit Report(Report* p, const QString& cmd = QString());
~Report();
~Report() override;
Q_SIGNALS:
void outputChanged();


Loading…
Cancel
Save