mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
solid: create a static KDeviceDatabase instance instead of one per-device
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c63f00ec2a
commit
ed0a14faf8
4 changed files with 16 additions and 13 deletions
|
@ -24,12 +24,17 @@
|
||||||
#include "devinfonetworkinterface.h"
|
#include "devinfonetworkinterface.h"
|
||||||
#include "devinfographic.h"
|
#include "devinfographic.h"
|
||||||
|
|
||||||
|
#include "kdevicedatabase.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <devinfo.h>
|
#include <devinfo.h>
|
||||||
|
|
||||||
|
|
||||||
|
static KDeviceDatabase s_devicedb;
|
||||||
|
|
||||||
using namespace Solid::Backends::Devinfo;
|
using namespace Solid::Backends::Devinfo;
|
||||||
|
|
||||||
typedef QMap<DevinfoDevice::DeviceProperty, QByteArray> DevicePropertiesType;
|
typedef QMap<DevinfoDevice::DeviceProperty, QByteArray> DevicePropertiesType;
|
||||||
|
@ -132,9 +137,9 @@ QString DevinfoDevice::vendor() const
|
||||||
const QByteArray parent = deviceProperty(DevinfoDevice::DeviceParent);
|
const QByteArray parent = deviceProperty(DevinfoDevice::DeviceParent);
|
||||||
QString result;
|
QString result;
|
||||||
if (parent.contains("pci")) {
|
if (parent.contains("pci")) {
|
||||||
result = m_devicedb.lookupPCIVendor(pnpvendor);
|
result = s_devicedb.lookupPCIVendor(pnpvendor);
|
||||||
} else {
|
} else {
|
||||||
result = m_devicedb.lookupUSBVendor(pnpvendor);
|
result = s_devicedb.lookupUSBVendor(pnpvendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -163,9 +168,9 @@ QString DevinfoDevice::product() const
|
||||||
const QByteArray parent = deviceProperty(DevinfoDevice::DeviceParent);
|
const QByteArray parent = deviceProperty(DevinfoDevice::DeviceParent);
|
||||||
QString result;
|
QString result;
|
||||||
if (parent.contains("pci")) {
|
if (parent.contains("pci")) {
|
||||||
result = m_devicedb.lookupPCIDevice(pnpvendor, pnpdevice);
|
result = s_devicedb.lookupPCIDevice(pnpvendor, pnpdevice);
|
||||||
} else {
|
} else {
|
||||||
result = m_devicedb.lookupUSBDevice(pnpvendor, pnpdevice);
|
result = s_devicedb.lookupUSBDevice(pnpvendor, pnpdevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
#include <solid/ifaces/device.h>
|
#include <solid/ifaces/device.h>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
#include "kdevicedatabase.h"
|
|
||||||
|
|
||||||
namespace Solid
|
namespace Solid
|
||||||
{
|
{
|
||||||
namespace Backends
|
namespace Backends
|
||||||
|
@ -79,7 +77,6 @@ private:
|
||||||
QString m_device;
|
QString m_device;
|
||||||
QMap<DeviceProperty, QByteArray> m_properties;
|
QMap<DeviceProperty, QByteArray> m_properties;
|
||||||
QMap<PnPInfo, QByteArray> m_pnpinfo;
|
QMap<PnPInfo, QByteArray> m_pnpinfo;
|
||||||
mutable KDeviceDatabase m_devicedb;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include "kglobal.h"
|
#include "kglobal.h"
|
||||||
#include "klocale.h"
|
#include "klocale.h"
|
||||||
|
#include "kdevicedatabase.h"
|
||||||
|
|
||||||
#if defined(LIBCDIO_FOUND)
|
#if defined(LIBCDIO_FOUND)
|
||||||
#include "udevopticaldisc.h"
|
#include "udevopticaldisc.h"
|
||||||
|
@ -49,6 +50,8 @@
|
||||||
|
|
||||||
using namespace Solid::Backends::UDev;
|
using namespace Solid::Backends::UDev;
|
||||||
|
|
||||||
|
static KDeviceDatabase s_devicedb;
|
||||||
|
|
||||||
UDevDevice::UDevDevice(const UdevQt::Device device)
|
UDevDevice::UDevDevice(const UdevQt::Device device)
|
||||||
: Solid::Ifaces::Device()
|
: Solid::Ifaces::Device()
|
||||||
, m_device(device)
|
, m_device(device)
|
||||||
|
@ -101,9 +104,9 @@ QString UDevDevice::vendor() const
|
||||||
if (!idvendorid.isEmpty()) {
|
if (!idvendorid.isEmpty()) {
|
||||||
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
||||||
if (idbus == QLatin1String("pci")) {
|
if (idbus == QLatin1String("pci")) {
|
||||||
vendor = m_devicedb.lookupPCIVendor(idvendorid);
|
vendor = s_devicedb.lookupPCIVendor(idvendorid);
|
||||||
} else if (idbus == QLatin1String("usb")) {
|
} else if (idbus == QLatin1String("usb")) {
|
||||||
vendor = m_devicedb.lookupUSBVendor(idvendorid);
|
vendor = s_devicedb.lookupUSBVendor(idvendorid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,9 +148,9 @@ QString UDevDevice::product() const
|
||||||
if (!idvendorid.isEmpty() && !idmodelid.isEmpty()) {
|
if (!idvendorid.isEmpty() && !idmodelid.isEmpty()) {
|
||||||
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
||||||
if (idbus == QLatin1String("pci")) {
|
if (idbus == QLatin1String("pci")) {
|
||||||
product = m_devicedb.lookupPCIDevice(idvendorid, idmodelid);
|
product = s_devicedb.lookupPCIDevice(idvendorid, idmodelid);
|
||||||
} else if (idbus == QLatin1String("usb")) {
|
} else if (idbus == QLatin1String("usb")) {
|
||||||
product = m_devicedb.lookupUSBDevice(idvendorid, idmodelid);
|
product = s_devicedb.lookupUSBDevice(idvendorid, idmodelid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define SOLID_BACKENDS_UDEV_UDEVDEVICE_H
|
#define SOLID_BACKENDS_UDEV_UDEVDEVICE_H
|
||||||
|
|
||||||
#include "udevqt.h"
|
#include "udevqt.h"
|
||||||
#include "kdevicedatabase.h"
|
|
||||||
|
|
||||||
#include <solid/ifaces/device.h>
|
#include <solid/ifaces/device.h>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
@ -64,7 +63,6 @@ private:
|
||||||
friend class AcAdapter;
|
friend class AcAdapter;
|
||||||
friend class Battery;
|
friend class Battery;
|
||||||
UdevQt::Device m_device;
|
UdevQt::Device m_device;
|
||||||
mutable KDeviceDatabase m_devicedb;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue