solid: return QByteArray object from UdevQt::Device::subsystem()

it is handled as latin1 anyway

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-09-07 08:30:09 +03:00
parent d69e5328dd
commit 35241fbc27
5 changed files with 20 additions and 20 deletions

View file

@ -103,7 +103,7 @@ Solid::AudioInterface::SoundcardType UdevAudioInterfacePrivate::soundcardType()
} }
else else
{ {
QString busName = parentDevice.subsystem(); QByteArray busName = parentDevice.subsystem();
QString driverName = parentDevice.driver(); QString driverName = parentDevice.driver();
if (busName == "ieee1394") if (busName == "ieee1394")
{ {

View file

@ -75,7 +75,7 @@ QString UDevDevice::parentUdi() const
// code in several places expects the parent to NOT be the actual parent (disk) device UDI even // code in several places expects the parent to NOT be the actual parent (disk) device UDI even
// for partitions but another device UDI related to this device, has to be fixed and verified // for partitions but another device UDI related to this device, has to be fixed and verified
// to work at some point // to work at some point
if (m_device.subsystem() == QLatin1String("block") || idcdrom == 1) { if (m_device.subsystem() == "block" || idcdrom == 1) {
return devicePath(); return devicePath();
} }
@ -531,13 +531,13 @@ bool UDevDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type)
case Solid::DeviceInterface::StorageAccess: case Solid::DeviceInterface::StorageAccess:
case Solid::DeviceInterface::StorageDrive: case Solid::DeviceInterface::StorageDrive:
case Solid::DeviceInterface::StorageVolume: { case Solid::DeviceInterface::StorageVolume: {
return m_device.subsystem() == QLatin1String("block"); return m_device.subsystem() == "block";
} }
case Solid::DeviceInterface::AcAdapter: { case Solid::DeviceInterface::AcAdapter: {
const QString powersupplytype = deviceProperty("POWER_SUPPLY_TYPE").toLower(); const QString powersupplytype = deviceProperty("POWER_SUPPLY_TYPE").toLower();
return ( return (
m_device.subsystem() == QLatin1String("power_supply") m_device.subsystem() == "power_supply"
&& (powersupplytype == QLatin1String("mains") && (powersupplytype == QLatin1String("mains")
|| powersupplytype.contains(QLatin1String("ups"))) || powersupplytype.contains(QLatin1String("ups")))
); );
@ -545,7 +545,7 @@ bool UDevDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type)
case Solid::DeviceInterface::Battery: { case Solid::DeviceInterface::Battery: {
const QString powersupplytype = deviceProperty("POWER_SUPPLY_TYPE").toLower(); const QString powersupplytype = deviceProperty("POWER_SUPPLY_TYPE").toLower();
return ( return (
m_device.subsystem() == QLatin1String("power_supply") && m_device.subsystem() == "power_supply" &&
(powersupplytype == QLatin1String("battery") (powersupplytype == QLatin1String("battery")
|| powersupplytype.contains(QLatin1String("usb"))) || powersupplytype.contains(QLatin1String("usb")))
); );
@ -570,13 +570,13 @@ bool UDevDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type)
return !deviceProperty("MAJOR").isEmpty(); return !deviceProperty("MAJOR").isEmpty();
case Solid::DeviceInterface::Video: case Solid::DeviceInterface::Video:
return m_device.subsystem() == QLatin1String("video4linux"); return m_device.subsystem() == "video4linux";
case Solid::DeviceInterface::AudioInterface: case Solid::DeviceInterface::AudioInterface:
return m_device.subsystem() == QLatin1String("sound"); return m_device.subsystem() == "sound";
case Solid::DeviceInterface::NetworkInterface: case Solid::DeviceInterface::NetworkInterface:
return m_device.subsystem() == QLatin1String("net"); return m_device.subsystem() == "net";
case Solid::DeviceInterface::Button: case Solid::DeviceInterface::Button:
return deviceProperty("ID_INPUT_KEY").toInt() == 1; return deviceProperty("ID_INPUT_KEY").toInt() == 1;

View file

@ -97,31 +97,31 @@ bool UDevManager::Private::checkOfInterest(const UdevQt::Device &device)
qDebug() << "Subsystem:" << device.subsystem(); qDebug() << "Subsystem:" << device.subsystem();
qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
#endif #endif
if (device.subsystem() == QLatin1String("block")) { if (device.subsystem() == "block") {
return !device.deviceProperty("ID_FS_TYPE").isEmpty(); return !device.deviceProperty("ID_FS_TYPE").isEmpty();
} }
if (device.subsystem() == QLatin1String("power_supply")) { if (device.subsystem() == "power_supply") {
return true; return true;
} }
if (device.driver() == QLatin1String("processor")) { if (device.driver() == "processor") {
// Linux ACPI reports processor slots, rather than processors. // Linux ACPI reports processor slots, rather than processors.
// Empty slots will not have a system device associated with them. // Empty slots will not have a system device associated with them.
QDir sysfsDir(device.sysfsPath()); QDir sysfsDir(device.sysfsPath());
return (sysfsDir.exists("sysdev") || sysfsDir.exists("cpufreq") || sysfsDir.exists("topology/core_id")); return (sysfsDir.exists("sysdev") || sysfsDir.exists("cpufreq") || sysfsDir.exists("topology/core_id"));
} }
if (device.subsystem() == QLatin1String("sound") && if (device.subsystem() == "sound" &&
device.deviceProperty("SOUND_FORM_FACTOR") != "internal") { device.deviceProperty("SOUND_FORM_FACTOR") != "internal") {
return true; return true;
} }
if (device.subsystem() == QLatin1String("pci")) { if (device.subsystem() == "pci") {
const QString pciclass = device.deviceProperty("PCI_CLASS"); const QString pciclass = device.deviceProperty("PCI_CLASS");
return (pciclass == QLatin1String("30000")); // VGA controller return (pciclass == QLatin1String("30000")); // VGA controller
} }
if (device.subsystem() == QLatin1String("input")) { if (device.subsystem() == "input") {
const QStringList deviceProperties = device.deviceProperties(); const QStringList deviceProperties = device.deviceProperties();
// key // key
if (device.deviceProperty("ID_INPUT_KEY").toInt() == 1 if (device.deviceProperty("ID_INPUT_KEY").toInt() == 1
@ -137,8 +137,8 @@ bool UDevManager::Private::checkOfInterest(const UdevQt::Device &device)
return false; return false;
} }
return device.subsystem() == QLatin1String("video4linux") || return device.subsystem() == "video4linux" ||
device.subsystem() == QLatin1String("net") || device.subsystem() == "net" ||
device.deviceProperty("ID_MEDIA_PLAYER").toInt() == 1 || // media-player-info recognized devices device.deviceProperty("ID_MEDIA_PLAYER").toInt() == 1 || // media-player-info recognized devices
(device.deviceProperty("ID_GPHOTO2").toInt() == 1 && device.parent().deviceProperty("ID_GPHOTO2").toInt() != 1); // GPhoto2 cameras (device.deviceProperty("ID_GPHOTO2").toInt() == 1 && device.parent().deviceProperty("ID_GPHOTO2").toInt() != 1); // GPhoto2 cameras
} }

View file

@ -47,7 +47,7 @@ public:
Device &operator= (const Device &other); Device &operator= (const Device &other);
bool isValid() const; bool isValid() const;
QString subsystem() const; QByteArray subsystem() const;
QString devType() const; QString devType() const;
QString name() const; QString name() const;
QString sysfsPath() const; QString sysfsPath() const;

View file

@ -69,12 +69,12 @@ bool Device::isValid() const
return (m_device != nullptr); return (m_device != nullptr);
} }
QString Device::subsystem() const QByteArray Device::subsystem() const
{ {
if (!m_device) { if (!m_device) {
return QString(); return QByteArray();
} }
return QString::fromLatin1(udev_device_get_subsystem(m_device)); return QByteArray(udev_device_get_subsystem(m_device));
} }
QString Device::devType() const QString Device::devType() const