2020-09-20 20:33:16 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include "backend/corebackend.h"
|
|
|
|
|
|
|
|
#include "core/device.h"
|
|
|
|
#include "core/partitiontable.h"
|
|
|
|
|
|
|
|
#include "util/globallog.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
2021-11-29 14:14:57 +00:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <KLocalizedString>
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2018-03-31 22:08:55 +01:00
|
|
|
struct CoreBackendPrivate
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
2018-03-31 22:08:55 +01:00
|
|
|
QString m_id, m_version;
|
2015-06-04 01:29:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
CoreBackend::CoreBackend() :
|
2018-03-31 12:56:34 +01:00
|
|
|
d(std::make_unique<CoreBackendPrivate>())
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreBackend::~CoreBackend()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-11-29 14:14:57 +00:00
|
|
|
bool CoreBackend::isPolkitInstalledCorrectly() {
|
|
|
|
// Assume PACKAGE_DATA_DIR is /usr/share, this is defined on polkit on buildtime so this might be wrong.
|
|
|
|
// This is a warning, not a hard failure, so it does not matter much.
|
|
|
|
QFileInfo fInfo(QStringLiteral("/usr/share/polkit-1/actions/org.kde.kpmcore.externalcommand.policy"));
|
|
|
|
|
|
|
|
// TODO: Port kpm to qCDebug, currently everything is debug.
|
|
|
|
if (!fInfo.exists()) {
|
|
|
|
qDebug() << "Installation might be wrong, we can't locate `org.kde.kpmcore.externalcommand.policy` on the polkit actions folder.";
|
|
|
|
qDebug() << "Please check if your Installation is on a different prefix and copy it to /usr/share/polkit-1/actions";
|
|
|
|
qDebug() << "That's specified for your distro. Since this is distro specific, you need to look at your distribution documentation.";
|
|
|
|
}
|
|
|
|
return fInfo.exists();
|
|
|
|
}
|
|
|
|
|
2015-06-04 01:29:22 +01:00
|
|
|
void CoreBackend::emitProgress(int i)
|
|
|
|
{
|
2020-09-15 02:36:46 +01:00
|
|
|
Q_EMIT progress(i);
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 03:08:05 +01:00
|
|
|
void CoreBackend::emitScanProgress(const QString& deviceNode, int i)
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
2020-09-15 02:36:46 +01:00
|
|
|
Q_EMIT scanProgress(deviceNode, i);
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoreBackend::setPartitionTableForDevice(Device& d, PartitionTable* p)
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
d.setPartitionTable(p);
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoreBackend::setPartitionTableMaxPrimaries(PartitionTable& p, qint32 max_primaries)
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
p.setMaxPrimaries(max_primaries);
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
2018-03-31 22:08:55 +01:00
|
|
|
|
2018-04-01 18:46:26 +01:00
|
|
|
QString CoreBackend::id()
|
|
|
|
{
|
2018-03-31 22:08:55 +01:00
|
|
|
return d->m_id;
|
|
|
|
}
|
|
|
|
|
2018-04-01 18:46:26 +01:00
|
|
|
QString CoreBackend::version()
|
|
|
|
{
|
2018-03-31 22:08:55 +01:00
|
|
|
return d->m_version;
|
|
|
|
}
|
|
|
|
|
2018-04-01 18:46:26 +01:00
|
|
|
void CoreBackend::setId(const QString& id)
|
|
|
|
{
|
2018-03-31 22:08:55 +01:00
|
|
|
d->m_id = id;
|
|
|
|
}
|
2018-03-31 23:49:37 +01:00
|
|
|
|
2018-04-01 18:46:26 +01:00
|
|
|
void CoreBackend::setVersion(const QString& version)
|
|
|
|
{
|
2018-03-31 22:08:55 +01:00
|
|
|
d->m_version = version;
|
|
|
|
}
|