File indexing completed on 2024-05-05 05:48:38
0001 /* 0002 SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> 0005 0006 SPDX-License-Identifier: GPL-3.0-or-later 0007 */ 0008 0009 #include "backend/corebackend.h" 0010 0011 #include "core/device.h" 0012 #include "core/partitiontable.h" 0013 0014 #include "util/globallog.h" 0015 0016 #include <QDebug> 0017 #include <QFileInfo> 0018 #include <KLocalizedString> 0019 0020 struct CoreBackendPrivate 0021 { 0022 QString m_id, m_version; 0023 }; 0024 0025 CoreBackend::CoreBackend() : 0026 d(std::make_unique<CoreBackendPrivate>()) 0027 { 0028 } 0029 0030 CoreBackend::~CoreBackend() 0031 { 0032 } 0033 0034 bool CoreBackend::isPolkitInstalledCorrectly() { 0035 // Assume PACKAGE_DATA_DIR is /usr/share, this is defined on polkit on buildtime so this might be wrong. 0036 // This is a warning, not a hard failure, so it does not matter much. 0037 QFileInfo fInfo(QStringLiteral("/usr/share/polkit-1/actions/org.kde.kpmcore.externalcommand.policy")); 0038 0039 // TODO: Port kpm to qCDebug, currently everything is debug. 0040 if (!fInfo.exists()) { 0041 qDebug() << "Installation might be wrong, we can't locate `org.kde.kpmcore.externalcommand.policy` on the polkit actions folder."; 0042 qDebug() << "Please check if your Installation is on a different prefix and copy it to /usr/share/polkit-1/actions"; 0043 qDebug() << "That's specified for your distro. Since this is distro specific, you need to look at your distribution documentation."; 0044 } 0045 return fInfo.exists(); 0046 } 0047 0048 void CoreBackend::emitProgress(int i) 0049 { 0050 Q_EMIT progress(i); 0051 } 0052 0053 void CoreBackend::emitScanProgress(const QString& deviceNode, int i) 0054 { 0055 Q_EMIT scanProgress(deviceNode, i); 0056 } 0057 0058 void CoreBackend::setPartitionTableForDevice(Device& d, PartitionTable* p) 0059 { 0060 d.setPartitionTable(p); 0061 } 0062 0063 void CoreBackend::setPartitionTableMaxPrimaries(PartitionTable& p, qint32 max_primaries) 0064 { 0065 p.setMaxPrimaries(max_primaries); 0066 } 0067 0068 QString CoreBackend::id() 0069 { 0070 return d->m_id; 0071 } 0072 0073 QString CoreBackend::version() 0074 { 0075 return d->m_version; 0076 } 0077 0078 void CoreBackend::setId(const QString& id) 0079 { 0080 d->m_id = id; 0081 } 0082 0083 void CoreBackend::setVersion(const QString& version) 0084 { 0085 d->m_version = version; 0086 } 0087 0088 #include "moc_corebackend.cpp"