Merge branch 'master' into kauth

This commit is contained in:
Andrius Štikonas 2018-04-09 12:44:14 +01:00
commit ee2688d4d9
10 changed files with 32 additions and 27 deletions

View File

@ -1,6 +1,6 @@
/************************************************************************* /*************************************************************************
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> * * Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> * * Copyright (C) 2016-2018 by Andrius Štikonas <andrius@stikonas.eu> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *

View File

@ -167,13 +167,13 @@ QString Partition::deviceNode() const
if (roles().has(PartitionRole::None) || roles().has(PartitionRole::Unallocated)) if (roles().has(PartitionRole::None) || roles().has(PartitionRole::Unallocated))
return xi18nc("@item partition name", "unallocated"); return xi18nc("@item partition name", "unallocated");
if (state() == StateNew) if (state() == State::New)
return xi18nc("@item partition name", "New Partition"); return xi18nc("@item partition name", "New Partition");
if (state() == StateRestore) if (state() == State::Restore)
return xi18nc("@item partition name", "Restored Partition"); return xi18nc("@item partition name", "Restored Partition");
if (state() == StateCopy) if (state() == State::Copy)
return xi18nc("@item partition name", "Copy of %1", partitionPath()); return xi18nc("@item partition name", "Copy of %1", partitionPath());
return partitionPath(); return partitionPath();

View File

@ -15,8 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#if !defined(KPMCORE_PARTITION_H) #ifndef KPMCORE_PARTITION_H
#define KPMCORE_PARTITION_H #define KPMCORE_PARTITION_H
#include "core/partitionnode.h" #include "core/partitionnode.h"
@ -77,13 +76,17 @@ class LIBKPMCORE_EXPORT Partition : public PartitionNode
public: public:
/** A Partition state -- where did it come from? */ /** A Partition state -- where did it come from? */
enum State { enum State {
StateNone = 0, /**< exists on disk */ None, /**< exists on disk */
StateNew = 1, /**< from a NewOperation */ New, /**< from a NewOperation */
StateCopy = 2, /**< from a CopyOperation */ Copy, /**< from a CopyOperation */
StateRestore = 3 /**< from a RestoreOperation */ Restore, /**< from a RestoreOperation */
StateNone = 0, /**< deprecated */
StateNew = 1, /**< deprecated */
StateCopy = 2, /**< deprecated */
StateRestore = 3 /**< deprecated */
}; };
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = StateNone); Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = State::None);
~Partition() override; ~Partition() override;
Partition(const Partition& other, PartitionNode* parent = nullptr); Partition(const Partition& other, PartitionNode* parent = nullptr);

View File

@ -62,7 +62,7 @@ bool CreatePartitionJob::run(Report& parent)
if (partitionPath != QString()) { if (partitionPath != QString()) {
rval = true; rval = true;
partition().setPartitionPath(partitionPath); partition().setPartitionPath(partitionPath);
partition().setState(Partition::StateNone); partition().setState(Partition::State::None);
backendPartitionTable->commit(); backendPartitionTable->commit();
} else } else
report->line() << xi18nc("@info/plain", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode()); report->line() << xi18nc("@info/plain", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode());
@ -72,7 +72,7 @@ bool CreatePartitionJob::run(Report& parent)
report->line() << xi18nc("@info:progress", "Could not open device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode()); report->line() << xi18nc("@info:progress", "Could not open device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
} else if (device().type() == Device::Type::LVM_Device) { } else if (device().type() == Device::Type::LVM_Device) {
LvmDevice& dev = dynamic_cast<LvmDevice&>(device()); LvmDevice& dev = dynamic_cast<LvmDevice&>(device());
partition().setState(Partition::StateNone); partition().setState(Partition::State::None);
QString partPath = partition().partitionPath(); QString partPath = partition().partitionPath();
QString lvname = partPath.right(partPath.length() - partPath.lastIndexOf(QStringLiteral("/")) - 1); QString lvname = partPath.right(partPath.length() - partPath.lastIndexOf(QStringLiteral("/")) - 1);

View File

@ -61,7 +61,7 @@ bool BackupOperation::canBackup(const Partition* p)
if (p->isMounted()) if (p->isMounted())
return false; return false;
if (p->state() == Partition::StateNew || p->state() == Partition::StateCopy || p->state() == Partition::StateRestore) if (p->state() == Partition::State::New || p->state() == Partition::State::Copy || p->state() == Partition::State::Restore)
return false; return false;
return p->fileSystem().supportBackup() != FileSystem::cmdSupportNone; return p->fileSystem().supportBackup() != FileSystem::cmdSupportNone;

View File

@ -137,7 +137,7 @@ bool CopyOperation::execute(Report& parent)
// set the state of the target partition from StateCopy to StateNone or checking // set the state of the target partition from StateCopy to StateNone or checking
// it will fail (because its deviceNode() will still be "Copy of sdXn"). This is // it will fail (because its deviceNode() will still be "Copy of sdXn"). This is
// only required for overwritten partitions, but doesn't hurt in any case. // only required for overwritten partitions, but doesn't hurt in any case.
copiedPartition().setState(Partition::StateNone); copiedPartition().setState(Partition::State::None);
// if we have overwritten a partition, reset device path and number // if we have overwritten a partition, reset device path and number
if (overwrittenPartition()) { if (overwrittenPartition()) {
@ -237,7 +237,7 @@ void CopyOperation::setOverwrittenPartition(Partition* p)
// have executed and we're asked to clean up after ourselves, the state of the overwritten partition // have executed and we're asked to clean up after ourselves, the state of the overwritten partition
// might have changed: If it was a new one and the NewOperation has successfully run, the state will // might have changed: If it was a new one and the NewOperation has successfully run, the state will
// then be StateNone. // then be StateNone.
m_MustDeleteOverwritten = (p && p->state() == Partition::StateNone); m_MustDeleteOverwritten = (p && p->state() == Partition::State::None);
} }
void CopyOperation::cleanupOverwrittenPartition() void CopyOperation::cleanupOverwrittenPartition()
@ -259,7 +259,7 @@ Partition* CopyOperation::createCopy(const Partition& target, const Partition& s
p->setDevicePath(source.devicePath()); p->setDevicePath(source.devicePath());
p->setPartitionPath(source.partitionPath()); p->setPartitionPath(source.partitionPath());
p->setState(Partition::StateCopy); p->setState(Partition::State::Copy);
p->deleteFileSystem(); p->deleteFileSystem();
p->setFileSystem(FileSystemFactory::create(source.fileSystem())); p->setFileSystem(FileSystemFactory::create(source.fileSystem()));
@ -281,7 +281,7 @@ bool CopyOperation::canCopy(const Partition* p)
if (p == nullptr) if (p == nullptr)
return false; return false;
if (p->state() == Partition::StateNew && p->roles().has(PartitionRole::Luks)) if (p->state() == Partition::State::New && p->roles().has(PartitionRole::Luks))
return false; return false;
if (p->isMounted()) if (p->isMounted())

View File

@ -128,7 +128,7 @@ Partition* NewOperation::createNew(const Partition& cloneFrom,
p->firstSector(), p->firstSector(),
p->lastSector(), p->lastSector(),
p->sectorSize())); p->sectorSize()));
p->setState(Partition::StateNew); p->setState(Partition::State::New);
p->setPartitionPath(QString()); p->setPartitionPath(QString());
return p; return p;

View File

@ -333,7 +333,7 @@ bool ResizeOperation::canGrow(const Partition* p)
return false; return false;
// we can always grow, shrink or move a partition not yet written to disk // we can always grow, shrink or move a partition not yet written to disk
if (p->state() == Partition::StateNew && !p->roles().has(PartitionRole::Luks)) if (p->state() == Partition::State::New && !p->roles().has(PartitionRole::Luks))
return true; return true;
if (p->isMounted()) if (p->isMounted())
@ -352,10 +352,10 @@ bool ResizeOperation::canShrink(const Partition* p)
return false; return false;
// we can always grow, shrink or move a partition not yet written to disk // we can always grow, shrink or move a partition not yet written to disk
if (p->state() == Partition::StateNew && !p->roles().has(PartitionRole::Luks)) if (p->state() == Partition::State::New && !p->roles().has(PartitionRole::Luks))
return true; return true;
if (p->state() == Partition::StateCopy) if (p->state() == Partition::State::Copy)
return false; return false;
if (p->isMounted()) if (p->isMounted())
@ -374,7 +374,7 @@ bool ResizeOperation::canMove(const Partition* p)
return false; return false;
// we can always grow, shrink or move a partition not yet written to disk // we can always grow, shrink or move a partition not yet written to disk
if (p->state() == Partition::StateNew) if (p->state() == Partition::State::New)
// too many bad things can happen for LUKS partitions // too many bad things can happen for LUKS partitions
return p->roles().has(PartitionRole::Luks) ? false : true; return p->roles().has(PartitionRole::Luks) ? false : true;

View File

@ -60,7 +60,7 @@ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filen
m_CheckTargetJob(nullptr), m_CheckTargetJob(nullptr),
m_MaximizeJob(nullptr) m_MaximizeJob(nullptr)
{ {
restorePartition().setState(Partition::StateRestore); restorePartition().setState(Partition::State::Restore);
Q_ASSERT(targetDevice().partitionTable()); Q_ASSERT(targetDevice().partitionTable());
@ -128,7 +128,7 @@ bool RestoreOperation::execute(Report& parent)
restorePartition().setPartitionPath(overwrittenPartition()->devicePath()); restorePartition().setPartitionPath(overwrittenPartition()->devicePath());
if (overwrittenPartition() || (rval = createPartitionJob()->run(*report))) { if (overwrittenPartition() || (rval = createPartitionJob()->run(*report))) {
restorePartition().setState(Partition::StateNone); restorePartition().setState(Partition::State::None);
if ((rval = restoreJob()->run(*report))) { if ((rval = restoreJob()->run(*report))) {
if ((rval = checkTargetJob()->run(*report))) { if ((rval = checkTargetJob()->run(*report))) {
@ -173,7 +173,7 @@ void RestoreOperation::setOverwrittenPartition(Partition* p)
cleanupOverwrittenPartition(); cleanupOverwrittenPartition();
m_OverwrittenPartition = p; m_OverwrittenPartition = p;
m_MustDeleteOverwritten = (p && p->state() == Partition::StateNone); m_MustDeleteOverwritten = (p && p->state() == Partition::State::None);
} }
void RestoreOperation::cleanupOverwrittenPartition() void RestoreOperation::cleanupOverwrittenPartition()
@ -227,7 +227,7 @@ Partition* RestoreOperation::createRestorePartition(const Device& device, Partit
const qint64 end = start + fileInfo.size() / device.logicalSize() - 1; const qint64 end = start + fileInfo.size() / device.logicalSize() - 1;
Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Type::Unknown, start, end, device.logicalSize()), start, end, QString()); Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Type::Unknown, start, end, device.logicalSize()), start, end, QString());
p->setState(Partition::StateRestore); p->setState(Partition::State::Restore);
return p; return p;
} }

View File

@ -19,6 +19,7 @@
"Description[sv]": "Ett bakgrundsprogram till KDE:s partitionshanterare i testsyfte.", "Description[sv]": "Ett bakgrundsprogram till KDE:s partitionshanterare i testsyfte.",
"Description[uk]": "Тестовий додаток сервера Керування розділами KDE.", "Description[uk]": "Тестовий додаток сервера Керування розділами KDE.",
"Description[x-test]": "xxA KDE Partition Manager dummy backend for testing purposes.xx", "Description[x-test]": "xxA KDE Partition Manager dummy backend for testing purposes.xx",
"Description[zh_CN]": "测试用的 KDE 分区管理器的虚拟后端",
"EnabledByDefault": true, "EnabledByDefault": true,
"Icon": "preferences-plugin", "Icon": "preferences-plugin",
"Id": "pmdummybackendplugin", "Id": "pmdummybackendplugin",
@ -40,6 +41,7 @@
"Name[sv]": "KDE:s partitionshanterare bakgrundsprogram för test", "Name[sv]": "KDE:s partitionshanterare bakgrundsprogram för test",
"Name[uk]": "Тестовий додаток сервера Керування розділами KDE", "Name[uk]": "Тестовий додаток сервера Керування розділами KDE",
"Name[x-test]": "xxKDE Partition Manager Dummy Backendxx", "Name[x-test]": "xxKDE Partition Manager Dummy Backendxx",
"Name[zh_CN]": "KDE 分区管理器虚拟后端",
"ServiceTypes": [ "ServiceTypes": [
"PartitionManager/Plugin" "PartitionManager/Plugin"
], ],