mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
solid: remove geom backend
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
01b877c90f
commit
a90855bddb
23 changed files with 2 additions and 1331 deletions
|
@ -206,14 +206,6 @@ set_package_properties(Devinfo PROPERTIES
|
|||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
macro_optional_find_package(Geom)
|
||||
set_package_properties(Geom PROPERTIES
|
||||
DESCRIPTION "Geom support for Solid"
|
||||
URL "https://www.freebsd.org/cgi/man.cgi?query=gctl_free"
|
||||
PURPOSE "Allows Solid to use Geom to provide information about devices on FreeBSD"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
macro_optional_find_package(LibCDIO)
|
||||
set_package_properties(LibCDIO PROPERTIES
|
||||
DESCRIPTION "GNU Compact Disc Input and Control Library"
|
||||
|
|
|
@ -14,7 +14,6 @@ set(cmakeFilesDontInstall
|
|||
FindACL.cmake
|
||||
FindLibCDIO.cmake
|
||||
FindDevinfo.cmake
|
||||
FindGeom.cmake
|
||||
)
|
||||
|
||||
# Explicitly list all files which will be installed.
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
# Try to find geom, once done this will define:
|
||||
#
|
||||
# GEOM_FOUND - system has geom
|
||||
# GEOM_INCLUDES - the geom include directory
|
||||
# GEOM_LIBRARIES - the libraries needed to use geom
|
||||
#
|
||||
# Copyright (c) 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
find_path(GEOM_INCLUDES
|
||||
NAMES libgeom.h
|
||||
HINTS $ENV{GEOMDIR}/include
|
||||
)
|
||||
|
||||
find_library(GEOM_LIBRARIES
|
||||
NAMES geom
|
||||
HINTS $ENV{GEOMDIR}/lib
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Geom
|
||||
REQUIRED_VARS GEOM_LIBRARIES GEOM_INCLUDES
|
||||
)
|
||||
|
||||
mark_as_advanced(GEOM_INCLUDES GEOM_LIBRARIES)
|
|
@ -186,34 +186,12 @@ if(DEVINFO_FOUND)
|
|||
backends/devinfo/devinfoprocessor.cpp
|
||||
backends/devinfo/devinfonetworkinterface.cpp
|
||||
backends/devinfo/devinfographic.cpp
|
||||
backends/devinfo/devdqt.cpp
|
||||
)
|
||||
|
||||
set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${DEVINFO_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(GEOM_FOUND)
|
||||
include_directories(${GEOM_INCLUDES})
|
||||
message(STATUS "Building Solid Geom backend.")
|
||||
set(solid_LIB_SRCS ${solid_LIB_SRCS}
|
||||
backends/geom/geomdevice.cpp
|
||||
backends/geom/geommanager.cpp
|
||||
backends/geom/geomdeviceinterface.cpp
|
||||
backends/geom/geomblock.cpp
|
||||
backends/geom/geomstoragedrive.cpp
|
||||
backends/geom/geomstoragevolume.cpp
|
||||
backends/geom/geomstorageaccess.cpp
|
||||
)
|
||||
|
||||
set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${QT_QTDBUS_LIBRARY} ${GEOM_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (DEVINFO_FOUND OR GEOM_FOUND)
|
||||
message(STATUS "Building device notification via devd.")
|
||||
set(solid_LIB_SRCS ${solid_LIB_SRCS}
|
||||
backends/shared/devdqt.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set_source_files_properties(
|
||||
org.freedesktop.PowerManagement.xml
|
||||
org.freedesktop.PowerManagement.Inhibit.xml
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <solid/ifaces/devicemanager.h>
|
||||
|
||||
#include "../shared/devdqt.h"
|
||||
#include "devdqt.h"
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geomblock.h"
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
Block::Block(GeomDevice *device)
|
||||
: DeviceInterface(device)
|
||||
{
|
||||
}
|
||||
|
||||
Block::~Block()
|
||||
{
|
||||
}
|
||||
|
||||
int Block::deviceMajor() const
|
||||
{
|
||||
return m_device->m_major;
|
||||
}
|
||||
|
||||
int Block::deviceMinor() const
|
||||
{
|
||||
return m_device->m_minor;
|
||||
}
|
||||
|
||||
QString Block::device() const
|
||||
{
|
||||
return QString::fromLatin1("/dev/%1").arg(m_device->m_realdevice.constData());
|
||||
}
|
||||
|
||||
#include "backends/geom/moc_geomblock.cpp"
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_GEOMBLOCK_H
|
||||
#define SOLID_BACKENDS_GEOM_GEOMBLOCK_H
|
||||
|
||||
#include <solid/ifaces/block.h>
|
||||
|
||||
#include "geomdeviceinterface.h"
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
class Block : public DeviceInterface, virtual public Solid::Ifaces::Block
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Solid::Ifaces::Block)
|
||||
|
||||
public:
|
||||
Block(GeomDevice *device);
|
||||
virtual ~Block();
|
||||
|
||||
virtual int deviceMajor() const;
|
||||
virtual int deviceMinor() const;
|
||||
virtual QString device() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SOLID_BACKENDS_GEOM_GEOMBLOCK_H
|
|
@ -1,282 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geommanager.h"
|
||||
#include "geomdevice.h"
|
||||
#include "geomblock.h"
|
||||
#include "geomstoragedrive.h"
|
||||
#include "geomstoragevolume.h"
|
||||
#include "geomstorageaccess.h"
|
||||
#include "kglobal.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <libgeom.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
GeomDevice::GeomDevice(const QString &device)
|
||||
: Solid::Ifaces::Device()
|
||||
, m_size(0)
|
||||
, m_device(device)
|
||||
, m_major(0)
|
||||
, m_minor(0)
|
||||
{
|
||||
m_realdevice = m_device.right(m_device.size() - qstrlen(GEOM_UDI_PREFIX) - 1).toLatin1();
|
||||
Q_ASSERT(!m_realdevice.contains('/'));
|
||||
int datapos = 0;
|
||||
int majornumberpos = 0;
|
||||
int minornumberpos = 0;
|
||||
const char* devicedata = m_realdevice.constData();
|
||||
while (*devicedata) {
|
||||
if (::isdigit(*devicedata)) {
|
||||
if (!majornumberpos) {
|
||||
majornumberpos = datapos;
|
||||
} else {
|
||||
minornumberpos = datapos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
devicedata++;
|
||||
datapos++;
|
||||
}
|
||||
m_parent = QByteArray(m_realdevice.constData(), majornumberpos);
|
||||
m_major = QByteArray(m_realdevice.constData() + majornumberpos, minornumberpos - majornumberpos).toInt();
|
||||
|
||||
struct gmesh tree;
|
||||
::memset(&tree, 0, sizeof(gmesh));
|
||||
const int geomresult = geom_gettree(&tree);
|
||||
struct gclass* geomclass = nullptr;
|
||||
struct ggeom* geomgeom = nullptr;
|
||||
struct gprovider* geomprovider = nullptr;
|
||||
struct gconfig* geomconfig = nullptr;
|
||||
LIST_FOREACH(geomclass, &tree.lg_class, lg_class) {
|
||||
LIST_FOREACH(geomgeom, &geomclass->lg_geom, lg_geom) {
|
||||
LIST_FOREACH(geomprovider, &geomgeom->lg_provider, lg_provider) {
|
||||
// qDebug() << geomgeom->lg_name << m_realdevice;
|
||||
if (qstrcmp(geomprovider->lg_name, m_realdevice.constData()) != 0) {
|
||||
continue;
|
||||
}
|
||||
LIST_FOREACH(geomconfig, &geomprovider->lg_config, lg_config) {
|
||||
// qDebug() << geomprovider->lg_name << geomconfig->lg_name << geomconfig->lg_val;
|
||||
if (qstrcmp(geomconfig->lg_name, "index") == 0) {
|
||||
m_minor = QByteArray(geomconfig->lg_val).toInt();
|
||||
} else if (qstrcmp(geomconfig->lg_name, "length") == 0) {
|
||||
m_size = QByteArray(geomconfig->lg_val).toULongLong();
|
||||
} else if (qstrcmp(geomconfig->lg_name, "type") == 0) {
|
||||
m_type = geomconfig->lg_val;
|
||||
} else if (qstrcmp(geomconfig->lg_name, "label") == 0) {
|
||||
m_label = geomconfig->lg_val;
|
||||
} else if (qstrcmp(geomconfig->lg_name, "rawuuid") == 0) {
|
||||
m_uuid = geomconfig->lg_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// NOTE: keep in sync with kdelibs/solid/solid/backends/geom/geommanager.cpp
|
||||
LIST_FOREACH(geomclass, &tree.lg_class, lg_class) {
|
||||
if (qstrcmp(geomclass->lg_name, "DISK") != 0 && qstrcmp(geomclass->lg_name, "PART") != 0
|
||||
&& qstrcmp(geomclass->lg_name, "SWAP") != 0) {
|
||||
continue;
|
||||
}
|
||||
LIST_FOREACH(geomgeom, &geomclass->lg_geom, lg_geom) {
|
||||
LIST_FOREACH(geomprovider, &geomgeom->lg_provider, lg_provider) {
|
||||
if (qstrcmp(geomprovider->lg_name, m_realdevice.constData()) != 0) {
|
||||
continue;
|
||||
}
|
||||
m_class = QByteArray(geomclass->lg_name).toLower();
|
||||
// qDebug() << m_realdevice << m_class;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
geom_deletetree(&tree);
|
||||
|
||||
// qDebug() << Q_FUNC_INFO << m_device << m_realdevice << m_parent << m_major << m_minor;
|
||||
// qDebug() << Q_FUNC_INFO << m_size << m_type << m_label << m_uuid << m_class;
|
||||
}
|
||||
|
||||
GeomDevice::~GeomDevice()
|
||||
{
|
||||
}
|
||||
|
||||
QString GeomDevice::udi() const
|
||||
{
|
||||
return QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, m_device);
|
||||
}
|
||||
|
||||
QString GeomDevice::parentUdi() const
|
||||
{
|
||||
#warning TODO: compatibility bits, see warning in kdelibs/solid/solid/backends/udev/udevdevice.cpp
|
||||
#if 0
|
||||
if (m_parent.isEmpty()) {
|
||||
return QString(GEOM_ROOT_UDI);
|
||||
}
|
||||
return QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, m_parent.constData());
|
||||
#else
|
||||
return QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, m_realdevice.constData());
|
||||
#endif
|
||||
}
|
||||
|
||||
QString GeomDevice::vendor() const
|
||||
{
|
||||
// no information related to vendor/product from geom
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString GeomDevice::product() const
|
||||
{
|
||||
if (m_device == GEOM_ROOT_UDI) {
|
||||
return QLatin1String("Devices");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString GeomDevice::icon() const
|
||||
{
|
||||
if (m_device == GEOM_ROOT_UDI) {
|
||||
return QString("computer");
|
||||
} else if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive)) {
|
||||
const StorageDrive storageIface(const_cast<GeomDevice *>(this));
|
||||
Solid::StorageDrive::DriveType drivetype = storageIface.driveType();
|
||||
|
||||
if (drivetype == Solid::StorageDrive::HardDisk) {
|
||||
return QLatin1String("drive-harddisk");
|
||||
} else if (drivetype == Solid::StorageDrive::CdromDrive) {
|
||||
return QLatin1String("drive-optical");
|
||||
} else if (drivetype == Solid::StorageDrive::Floppy) {
|
||||
return QLatin1String("media-floppy");
|
||||
} else if (drivetype == Solid::StorageDrive::Tape) {
|
||||
return QLatin1String("media-tape");
|
||||
} else if (drivetype == Solid::StorageDrive::CompactFlash) {
|
||||
return QLatin1String("drive-removable-media");
|
||||
} else if (drivetype == Solid::StorageDrive::MemoryStick) {
|
||||
return QLatin1String("media-flash-memory-stick");
|
||||
} else if (drivetype == Solid::StorageDrive::SmartMedia) {
|
||||
return QLatin1String("media-flash-smart-media");
|
||||
} else if (drivetype == Solid::StorageDrive::SdMmc) {
|
||||
return QLatin1String("media-flash-sd-mmc");
|
||||
} else if (drivetype == Solid::StorageDrive::Xd) {
|
||||
return QLatin1String("drive-removable-media");
|
||||
}
|
||||
} else if (queryDeviceInterface(Solid::DeviceInterface::StorageVolume)) {
|
||||
return QLatin1String("drive-harddisk");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QStringList GeomDevice::emblems() const
|
||||
{
|
||||
QStringList res;
|
||||
if (queryDeviceInterface(Solid::DeviceInterface::StorageAccess)) {
|
||||
const StorageAccess accessIface(const_cast<GeomDevice *>(this));
|
||||
if (accessIface.isAccessible()) {
|
||||
res << "emblem-mounted";
|
||||
} else {
|
||||
res << "emblem-unmounted";
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
QString GeomDevice::description() const
|
||||
{
|
||||
if (m_device == GEOM_ROOT_UDI || parentUdi().isEmpty()) {
|
||||
return QObject::tr("Computer");
|
||||
} else if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive)) {
|
||||
const StorageDrive storageIface(const_cast<GeomDevice *>(this));
|
||||
Solid::StorageDrive::DriveType drivetype = storageIface.driveType();
|
||||
const QString storagesize = KGlobal::locale()->formatByteSize(storageIface.size());
|
||||
|
||||
if (drivetype == Solid::StorageDrive::HardDisk) {
|
||||
return QObject::tr("%1 Hard Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::CdromDrive) {
|
||||
return QObject::tr("%1 CD-ROM Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::Floppy) {
|
||||
return QObject::tr("%1 Floppy Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::Tape) {
|
||||
return QObject::tr("%1 Tape Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::CompactFlash) {
|
||||
return QObject::tr("%1 Compact Flash Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::MemoryStick) {
|
||||
return QObject::tr("%1 Memory Stick Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::SmartMedia) {
|
||||
return QObject::tr("%1 Smart Media Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::SdMmc) {
|
||||
return QObject::tr("%1 SD/MMC Drive").arg(storagesize);
|
||||
} else if (drivetype == Solid::StorageDrive::Xd) {
|
||||
return QObject::tr("%1 Xd Drive").arg(storagesize);
|
||||
}
|
||||
} else if (queryDeviceInterface(Solid::DeviceInterface::StorageVolume)) {
|
||||
const StorageVolume storageIface(const_cast<GeomDevice *>(this));
|
||||
QString desc = storageIface.label();
|
||||
if (desc.isEmpty()) {
|
||||
desc = storageIface.uuid();
|
||||
}
|
||||
if (desc.isEmpty()) {
|
||||
desc = m_realdevice;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool GeomDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type) const
|
||||
{
|
||||
switch (type) {
|
||||
case Solid::DeviceInterface::Block:
|
||||
case Solid::DeviceInterface::StorageDrive:
|
||||
case Solid::DeviceInterface::StorageVolume:
|
||||
case Solid::DeviceInterface::StorageAccess: {
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QObject *GeomDevice::createDeviceInterface(const Solid::DeviceInterface::Type &type)
|
||||
{
|
||||
if (!queryDeviceInterface(type)) {
|
||||
return 0;
|
||||
}
|
||||
switch (type) {
|
||||
case Solid::DeviceInterface::Block: {
|
||||
return new Block(this);
|
||||
}
|
||||
case Solid::DeviceInterface::StorageDrive: {
|
||||
return new StorageDrive(this);
|
||||
}
|
||||
case Solid::DeviceInterface::StorageVolume: {
|
||||
return new StorageVolume(this);
|
||||
}
|
||||
case Solid::DeviceInterface::StorageAccess: {
|
||||
return new StorageAccess(this);
|
||||
}
|
||||
default: {
|
||||
Q_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_GEOMDEVICE_H
|
||||
#define SOLID_BACKENDS_GEOM_GEOMDEVICE_H
|
||||
|
||||
#include <solid/ifaces/device.h>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
|
||||
class GeomDevice : public Solid::Ifaces::Device
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeomDevice(const QString &device);
|
||||
virtual ~GeomDevice();
|
||||
|
||||
virtual QString udi() const;
|
||||
virtual QString parentUdi() const;
|
||||
virtual QString vendor() const;
|
||||
virtual QString product() const;
|
||||
virtual QString icon() const;
|
||||
virtual QStringList emblems() const;
|
||||
virtual QString description() const;
|
||||
virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type &type) const;
|
||||
virtual QObject *createDeviceInterface(const Solid::DeviceInterface::Type &type);
|
||||
|
||||
public:
|
||||
QString m_device;
|
||||
// synthetized
|
||||
QByteArray m_realdevice;
|
||||
QByteArray m_parent;
|
||||
// mostly populated from geom providers
|
||||
qulonglong m_size;
|
||||
QByteArray m_type;
|
||||
QByteArray m_label;
|
||||
QByteArray m_uuid;
|
||||
QByteArray m_class;
|
||||
int m_major; // this one is not
|
||||
int m_minor;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // SOLID_BACKENDS_GEOM_GEOMDEVICE_H
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geomdeviceinterface.h"
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
DeviceInterface::DeviceInterface(GeomDevice *device)
|
||||
: QObject(device), m_device(device)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceInterface::~DeviceInterface()
|
||||
{
|
||||
}
|
||||
|
||||
#include "backends/geom/moc_geomdeviceinterface.cpp"
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_DEVICEINTERFACE_H
|
||||
#define SOLID_BACKENDS_GEOM_DEVICEINTERFACE_H
|
||||
|
||||
#include <solid/ifaces/deviceinterface.h>
|
||||
#include "geomdevice.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
class DeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Solid::Ifaces::DeviceInterface)
|
||||
public:
|
||||
DeviceInterface(GeomDevice *device);
|
||||
virtual ~DeviceInterface();
|
||||
|
||||
protected:
|
||||
GeomDevice *m_device;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,202 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geommanager.h"
|
||||
#include "geomdevice.h"
|
||||
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <libgeom.h>
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
class GeomManager::Private
|
||||
{
|
||||
public:
|
||||
Private(GeomManager *parent);
|
||||
~Private();
|
||||
|
||||
bool isOfInterest(const QString &udi);
|
||||
|
||||
QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
|
||||
DevdQt::Client *m_client;
|
||||
GeomManager *m_parent;
|
||||
};
|
||||
|
||||
GeomManager::Private::Private(GeomManager *parent)
|
||||
: m_client(new DevdQt::Client()),
|
||||
m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
GeomManager::Private::~Private()
|
||||
{
|
||||
delete m_client;
|
||||
}
|
||||
|
||||
bool GeomManager::Private::isOfInterest(const QString &udi)
|
||||
{
|
||||
const QStringList allDev = m_parent->allDevices();
|
||||
return (allDev.contains(udi));
|
||||
}
|
||||
|
||||
GeomManager::GeomManager(QObject *parent)
|
||||
: Solid::Ifaces::DeviceManager(parent),
|
||||
d(new Private(this))
|
||||
{
|
||||
connect(d->m_client, SIGNAL(deviceAdded(DevdQt::Device)), this, SLOT(slotDeviceAdded(DevdQt::Device)));
|
||||
connect(d->m_client, SIGNAL(deviceRemoved(DevdQt::Device)), this, SLOT(slotDeviceRemoved(DevdQt::Device)));
|
||||
connect(d->m_client, SIGNAL(deviceChanged(DevdQt::Device)), this, SLOT(slotDeviceChanged(DevdQt::Device)));
|
||||
|
||||
d->m_supportedInterfaces
|
||||
<< Solid::DeviceInterface::Block
|
||||
<< Solid::DeviceInterface::StorageDrive
|
||||
<< Solid::DeviceInterface::StorageVolume
|
||||
<< Solid::DeviceInterface::StorageAccess;
|
||||
}
|
||||
|
||||
GeomManager::~GeomManager()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString GeomManager::udiPrefix() const
|
||||
{
|
||||
return QString(GEOM_UDI_PREFIX);
|
||||
}
|
||||
|
||||
QSet<Solid::DeviceInterface::Type> GeomManager::supportedInterfaces() const
|
||||
{
|
||||
return d->m_supportedInterfaces;
|
||||
}
|
||||
|
||||
QStringList GeomManager::allDevices()
|
||||
{
|
||||
QStringList result;
|
||||
|
||||
struct gmesh tree;
|
||||
::memset(&tree, 0, sizeof(gmesh));
|
||||
const int geomresult = geom_gettree(&tree);
|
||||
struct gclass* geomclass = nullptr;
|
||||
struct ggeom* geomgeom = nullptr;
|
||||
struct gprovider* geomprovider = nullptr;
|
||||
// NOTE: keep in sync with kdelibs/solid/solid/backends/geom/geomdevice.cpp
|
||||
LIST_FOREACH(geomclass, &tree.lg_class, lg_class) {
|
||||
// not interested in devices made up by providers such as labels
|
||||
if (qstrcmp(geomclass->lg_name, "DISK") != 0 && qstrcmp(geomclass->lg_name, "PART") != 0
|
||||
&& qstrcmp(geomclass->lg_name, "SWAP") != 0) {
|
||||
continue;
|
||||
}
|
||||
LIST_FOREACH(geomgeom, &geomclass->lg_geom, lg_geom) {
|
||||
LIST_FOREACH(geomprovider, &geomgeom->lg_provider, lg_provider) {
|
||||
// qDebug() << geomclass->lg_name << geomgeom->lg_name << geomprovider->lg_name;
|
||||
|
||||
// devices which are named like path should not be listed by manager, e.g.
|
||||
// gpt/swapfs or gptid/9d7008c3-990e-11eb-bf4c-002590ec5bf2. some of these are
|
||||
// label-like anyway (e.g. CD-ROM providers, they do not even have UUID) so filter
|
||||
// them the hard way
|
||||
if (::strchr(geomprovider->lg_name, '/') != NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString devudi = QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, geomprovider->lg_name);
|
||||
result << devudi;
|
||||
}
|
||||
}
|
||||
}
|
||||
geom_deletetree(&tree);
|
||||
|
||||
// qDebug() << Q_FUNC_INFO << result;
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList GeomManager::devicesFromQuery(const QString &parentUdi,
|
||||
Solid::DeviceInterface::Type type)
|
||||
{
|
||||
QStringList allDev = allDevices();
|
||||
QStringList result;
|
||||
|
||||
if (!parentUdi.isEmpty()) {
|
||||
foreach (const QString &udi, allDev) {
|
||||
GeomDevice device(udi);
|
||||
if (device.queryDeviceInterface(type) && device.parentUdi() == parentUdi) {
|
||||
result << udi;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else if (type != Solid::DeviceInterface::Unknown) {
|
||||
foreach (const QString &udi, allDev) {
|
||||
GeomDevice device(udi);
|
||||
if (device.queryDeviceInterface(type)) {
|
||||
result << udi;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return allDev;
|
||||
}
|
||||
}
|
||||
|
||||
QObject *GeomManager::createDevice(const QString &udi)
|
||||
{
|
||||
if (udi == udiPrefix()) {
|
||||
return new GeomDevice(GEOM_ROOT_UDI);
|
||||
}
|
||||
|
||||
if (!udi.isEmpty()) {
|
||||
return new GeomDevice(udi);
|
||||
}
|
||||
|
||||
qWarning() << "cannot create device for UDI" << udi;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GeomManager::slotDeviceAdded(const DevdQt::Device &device)
|
||||
{
|
||||
const QByteArray devname(device.device());
|
||||
const QString devstring = QString::fromLatin1(devname.constData(), devname.size());
|
||||
const QString devudi = QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, devstring);
|
||||
if (d->isOfInterest(devudi)) {
|
||||
emit deviceAdded(devudi);
|
||||
}
|
||||
}
|
||||
|
||||
void GeomManager::slotDeviceRemoved(const DevdQt::Device &device)
|
||||
{
|
||||
const QByteArray devname(device.device());
|
||||
const QString devstring = QString::fromLatin1(devname.constData(), devname.size());
|
||||
const QString devudi = QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, devstring);
|
||||
if (d->isOfInterest(devudi)) {
|
||||
emit deviceRemoved(devudi);
|
||||
}
|
||||
}
|
||||
|
||||
void GeomManager::slotDeviceChanged(const DevdQt::Device &device)
|
||||
{
|
||||
const QByteArray devname(device.device());
|
||||
const QString devstring = QString::fromLatin1(devname.constData(), devname.size());
|
||||
const QString devudi = QString::fromLatin1("%1/%2").arg(GEOM_UDI_PREFIX, devstring);
|
||||
if (d->isOfInterest(devudi)) {
|
||||
const GeomDevice geomdevice(devudi);
|
||||
const bool hascontent = (!geomdevice.m_type.isEmpty());
|
||||
emit contentChanged(devudi, hascontent);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_GEOMMANAGER_H
|
||||
#define SOLID_BACKENDS_GEOM_GEOMMANAGER_H
|
||||
|
||||
#define GEOM_ROOT_UDI "/org/kde/geom/geom0"
|
||||
#define GEOM_UDI_PREFIX "/org/kde/geom"
|
||||
|
||||
#include <solid/ifaces/devicemanager.h>
|
||||
|
||||
#include "../shared/devdqt.h"
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
class GeomManager : public Solid::Ifaces::DeviceManager
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeomManager(QObject *parent);
|
||||
virtual ~GeomManager();
|
||||
|
||||
virtual QString udiPrefix() const;
|
||||
virtual QSet<Solid::DeviceInterface::Type> supportedInterfaces() const;
|
||||
virtual QStringList allDevices();
|
||||
virtual QStringList devicesFromQuery(const QString &parentUdi,
|
||||
Solid::DeviceInterface::Type type);
|
||||
virtual QObject *createDevice(const QString &udi);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotDeviceAdded(const DevdQt::Device &device);
|
||||
void slotDeviceRemoved(const DevdQt::Device &device);
|
||||
void slotDeviceChanged(const DevdQt::Device &device);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *const d;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SOLID_BACKENDS_GEOM_GEOMMANAGER_H
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geomstorageaccess.h"
|
||||
#include "kstandarddirs.h"
|
||||
#include "kmountpoint.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
StorageAccess::StorageAccess(GeomDevice *device)
|
||||
: DeviceInterface(device)
|
||||
{
|
||||
}
|
||||
|
||||
StorageAccess::~StorageAccess()
|
||||
{
|
||||
}
|
||||
|
||||
bool StorageAccess::isAccessible() const
|
||||
{
|
||||
return !filePath().isEmpty();
|
||||
}
|
||||
|
||||
QString StorageAccess::filePath() const
|
||||
{
|
||||
const KMountPoint::List mountpoints = KMountPoint::currentMountPoints();
|
||||
|
||||
// TODO: use providers instead
|
||||
const QString devname(QString::fromLatin1("/dev/%1").arg(m_device->m_realdevice.constData()));
|
||||
const QString devgptname(QString::fromLatin1("/dev/gpt/%1").arg(m_device->m_realdevice.constData()));
|
||||
const QString devlabel(QString::fromLatin1("/dev/%1").arg(m_device->m_label.constData()));
|
||||
const QString devgptlabel(QString::fromLatin1("/dev/gpt/%1").arg(m_device->m_label.constData()));
|
||||
const QString devuuid(QString::fromLatin1("/dev/%1").arg(m_device->m_uuid.constData()));
|
||||
const QString devgptuuid(QString::fromLatin1("/dev/gpt/%1").arg(m_device->m_uuid.constData()));
|
||||
foreach (const KMountPoint::Ptr mountpoint, mountpoints) {
|
||||
// qDebug() << devname << devlabel << mountpoint->mountedFrom() << mountpoint->realDeviceName();
|
||||
if (mountpoint->mountedFrom() == devname || mountpoint->realDeviceName() == devname
|
||||
|| mountpoint->mountedFrom() == devgptname || mountpoint->realDeviceName() == devgptname
|
||||
|| mountpoint->mountedFrom() == devlabel || mountpoint->realDeviceName() == devlabel
|
||||
|| mountpoint->mountedFrom() == devgptlabel || mountpoint->realDeviceName() == devgptlabel
|
||||
|| mountpoint->mountedFrom() == devuuid || mountpoint->realDeviceName() == devgptuuid) {
|
||||
return mountpoint->mountPoint();
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool StorageAccess::isIgnored() const
|
||||
{
|
||||
// freebsd-swap and freebsd-boot type filesystems cannot be accessed
|
||||
return (m_device->m_type.isEmpty() || m_device->m_type == "freebsd-swap" || m_device->m_type == "freebsd-boot");
|
||||
}
|
||||
|
||||
bool StorageAccess::setup()
|
||||
{
|
||||
QString mountpoint = filePath();
|
||||
if (!mountpoint.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
emit setupRequested(m_device->udi());
|
||||
|
||||
QDBusInterface soliduiserver("org.kde.kded", "/modules/soliduiserver", "org.kde.SolidUiServer");
|
||||
QDBusReply<int> reply = soliduiserver.call("mountDevice", m_device->udi());
|
||||
|
||||
const Solid::ErrorType replyvalue = static_cast<Solid::ErrorType>(reply.value());
|
||||
if (replyvalue == Solid::NoError) {
|
||||
emit accessibilityChanged(true, m_device->udi());
|
||||
}
|
||||
|
||||
emit setupDone(replyvalue, Solid::errorString(replyvalue), m_device->udi());
|
||||
return (replyvalue == Solid::NoError);
|
||||
}
|
||||
|
||||
bool StorageAccess::teardown()
|
||||
{
|
||||
const QString mountpoint = filePath();
|
||||
if (mountpoint.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
emit teardownRequested(m_device->udi());
|
||||
|
||||
QDBusInterface soliduiserver("org.kde.kded", "/modules/soliduiserver", "org.kde.SolidUiServer");
|
||||
QDBusReply<int> reply = soliduiserver.call("unmountDevice", m_device->udi());
|
||||
|
||||
const Solid::ErrorType replyvalue = static_cast<Solid::ErrorType>(reply.value());
|
||||
if (replyvalue == Solid::NoError) {
|
||||
emit accessibilityChanged(false, m_device->udi());
|
||||
}
|
||||
|
||||
emit teardownDone(replyvalue, Solid::errorString(replyvalue), m_device->udi());
|
||||
return (replyvalue == Solid::NoError);
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_GEOMSTORAGEACCESS_H
|
||||
#define SOLID_BACKENDS_GEOM_GEOMSTORAGEACCESS_H
|
||||
|
||||
#include <solid/ifaces/storageaccess.h>
|
||||
#include "geomdeviceinterface.h"
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
class StorageAccess : public DeviceInterface, virtual public Solid::Ifaces::StorageAccess
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Solid::Ifaces::StorageAccess)
|
||||
|
||||
public:
|
||||
explicit StorageAccess(GeomDevice *device);
|
||||
virtual ~StorageAccess();
|
||||
|
||||
virtual bool isAccessible() const;
|
||||
virtual QString filePath() const;
|
||||
virtual bool isIgnored() const;
|
||||
virtual bool setup();
|
||||
virtual bool teardown();
|
||||
|
||||
Q_SIGNALS:
|
||||
void accessibilityChanged(bool accessible, const QString &udi);
|
||||
void setupDone(Solid::ErrorType error, QVariant data, const QString &udi);
|
||||
void teardownDone(Solid::ErrorType error, QVariant data, const QString &udi);
|
||||
void setupRequested(const QString &udi);
|
||||
void teardownRequested(const QString &udi);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SOLID_BACKENDS_GEOM_GEOMSTORAGEACCESS_H
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geomstoragedrive.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <libgeom.h>
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
StorageDrive::StorageDrive(GeomDevice *device)
|
||||
: Block(device)
|
||||
{
|
||||
}
|
||||
|
||||
StorageDrive::~StorageDrive()
|
||||
{
|
||||
}
|
||||
|
||||
qulonglong StorageDrive::size() const
|
||||
{
|
||||
return m_device->m_size;
|
||||
}
|
||||
|
||||
bool StorageDrive::isHotpluggable() const
|
||||
{
|
||||
const Solid::StorageDrive::Bus storagebus = bus();
|
||||
return (storagebus == Solid::StorageDrive::Usb || storagebus == Solid::StorageDrive::Ieee1394);
|
||||
}
|
||||
|
||||
bool StorageDrive::isRemovable() const
|
||||
{
|
||||
const Solid::StorageDrive::Bus storagebus = bus();
|
||||
return (storagebus == Solid::StorageDrive::Usb);
|
||||
}
|
||||
|
||||
Solid::StorageDrive::DriveType StorageDrive::driveType() const
|
||||
{
|
||||
// for reference:
|
||||
// https://docs.freebsd.org/doc/6.0-RELEASE/usr/share/doc/handbook/disks-naming.html
|
||||
// TODO: not implementd: MemoryStick, SmartMedia, SdMmc, Xd
|
||||
if (m_device->m_realdevice.startsWith("acd") || m_device->m_realdevice.startsWith("cd")
|
||||
|| m_device->m_realdevice.startsWith("mcd")) {
|
||||
return Solid::StorageDrive::CdromDrive;
|
||||
} else if (m_device->m_realdevice.startsWith("fd")) {
|
||||
return Solid::StorageDrive::Floppy;
|
||||
} else if (m_device->m_realdevice.startsWith("sa") || m_device->m_realdevice.startsWith("ast")) {
|
||||
return Solid::StorageDrive::Tape;
|
||||
} else if (m_device->m_realdevice.startsWith("da") || m_device->m_realdevice.startsWith("fla")) {
|
||||
return Solid::StorageDrive::CompactFlash;
|
||||
} else {
|
||||
return Solid::StorageDrive::HardDisk;
|
||||
}
|
||||
}
|
||||
|
||||
Solid::StorageDrive::Bus StorageDrive::bus() const
|
||||
{
|
||||
// TODO: not implemented: Sata, Ieee1394
|
||||
if (m_device->m_realdevice.startsWith("ad") || m_device->m_realdevice.startsWith("acd")
|
||||
|| m_device->m_realdevice.startsWith("ast")) {
|
||||
return Solid::StorageDrive::Ide;
|
||||
} else if (m_device->m_realdevice.startsWith("fla")) {
|
||||
return Solid::StorageDrive::Usb;
|
||||
} else if (m_device->m_realdevice.startsWith("da") || m_device->m_realdevice.startsWith("cd")
|
||||
|| m_device->m_realdevice.startsWith("sa")) {
|
||||
return Solid::StorageDrive::Scsi;
|
||||
} else {
|
||||
return Solid::StorageDrive::Platform;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_GEOMSTORAGEDRIVE_H
|
||||
#define SOLID_BACKENDS_GEOM_GEOMSTORAGEDRIVE_H
|
||||
|
||||
#include <ifaces/storagedrive.h>
|
||||
|
||||
#include "geomblock.h"
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
|
||||
class StorageDrive: public Block, virtual public Solid::Ifaces::StorageDrive
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Solid::Ifaces::StorageDrive)
|
||||
|
||||
public:
|
||||
StorageDrive(GeomDevice *device);
|
||||
virtual ~StorageDrive();
|
||||
|
||||
virtual qulonglong size() const;
|
||||
virtual bool isHotpluggable() const;
|
||||
virtual bool isRemovable() const;
|
||||
virtual Solid::StorageDrive::DriveType driveType() const;
|
||||
virtual Solid::StorageDrive::Bus bus() const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SOLID_BACKENDS_GEOM_GEOMSTORAGEDRIVE_H
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "geomstoragevolume.h"
|
||||
#include "geomdevice.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Solid::Backends::Geom;
|
||||
|
||||
StorageVolume::StorageVolume(GeomDevice *device)
|
||||
: Block(device)
|
||||
{
|
||||
}
|
||||
|
||||
StorageVolume::~StorageVolume()
|
||||
{
|
||||
}
|
||||
|
||||
QString StorageVolume::encryptedContainerUdi() const
|
||||
{
|
||||
// encrypted devices are not support
|
||||
return QString();
|
||||
}
|
||||
|
||||
qulonglong StorageVolume::size() const
|
||||
{
|
||||
return m_device->m_size;
|
||||
}
|
||||
|
||||
QString StorageVolume::uuid() const
|
||||
{
|
||||
return m_device->m_uuid;
|
||||
}
|
||||
|
||||
QString StorageVolume::label() const
|
||||
{
|
||||
return m_device->m_label;
|
||||
}
|
||||
|
||||
QString StorageVolume::fsType() const
|
||||
{
|
||||
return m_device->m_type;
|
||||
}
|
||||
|
||||
Solid::StorageVolume::UsageType StorageVolume::usage() const
|
||||
{
|
||||
// TODO: not implemented: Encrypted, Raid
|
||||
if (m_device->m_class == "swap" || m_device->m_type == "freebsd-swap"
|
||||
|| m_device->m_type == "freebsd-boot") {
|
||||
return Solid::StorageVolume::Other;
|
||||
} else if (!m_device->m_type.isEmpty()) {
|
||||
return Solid::StorageVolume::FileSystem;
|
||||
} else if (m_device->m_class == "disk" || m_device->m_class == "part") {
|
||||
return Solid::StorageVolume::PartitionTable;
|
||||
} else {
|
||||
return Solid::StorageVolume::Unused;
|
||||
}
|
||||
}
|
||||
|
||||
bool StorageVolume::isIgnored() const
|
||||
{
|
||||
const Solid::StorageVolume::UsageType volumeusage = usage();
|
||||
return (volumeusage != Solid::StorageVolume::FileSystem);
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SOLID_BACKENDS_GEOM_GEOMSTORAGEVOLUME_H
|
||||
#define SOLID_BACKENDS_GEOM_GEOMSTORAGEVOLUME_H
|
||||
|
||||
#include <ifaces/storagevolume.h>
|
||||
|
||||
#include "geomblock.h"
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
{
|
||||
namespace Geom
|
||||
{
|
||||
|
||||
class StorageVolume: public Block, virtual public Solid::Ifaces::StorageVolume
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Solid::Ifaces::StorageVolume)
|
||||
|
||||
public:
|
||||
StorageVolume(GeomDevice *device);
|
||||
virtual ~StorageVolume();
|
||||
|
||||
virtual QString encryptedContainerUdi() const;
|
||||
virtual qulonglong size() const;
|
||||
virtual QString uuid() const;
|
||||
virtual QString label() const;
|
||||
virtual QString fsType() const;
|
||||
virtual Solid::StorageVolume::UsageType usage() const;
|
||||
virtual bool isIgnored() const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SOLID_BACKENDS_GEOM_GEOMSTORAGEVOLUME_H
|
|
@ -20,5 +20,4 @@
|
|||
|
||||
#cmakedefine UDEV_FOUND
|
||||
#cmakedefine DEVINFO_FOUND
|
||||
#cmakedefine GEOM_FOUND
|
||||
#cmakedefine LIBCDIO_FOUND
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
#include "backends/devinfo/devinfomanager.h"
|
||||
#endif
|
||||
|
||||
#if defined (GEOM_FOUND)
|
||||
#include "backends/geom/geommanager.h"
|
||||
#endif
|
||||
|
||||
#if defined(UDEV_FOUND)
|
||||
#include "backends/udev/udevmanager.h"
|
||||
#endif
|
||||
|
@ -70,10 +66,6 @@ void Solid::ManagerBasePrivate::loadBackends()
|
|||
#if defined(DEVINFO_FOUND)
|
||||
m_backends << new Solid::Backends::Devinfo::DevinfoManager(0);
|
||||
#endif
|
||||
|
||||
#if defined(GEOM_FOUND)
|
||||
m_backends << new Solid::Backends::Geom::GeomManager(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
QList<QObject*> Solid::ManagerBasePrivate::managerBackends() const
|
||||
|
|
Loading…
Add table
Reference in a new issue