mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kinfocenter: add more paths to USB IDs database
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f5db354473
commit
2d70a55db3
3 changed files with 49 additions and 21 deletions
|
@ -60,6 +60,9 @@
|
|||
/* KDE's static data directory */
|
||||
#define KDE_DATADIR "${KDE4_DATA_INSTALL_DIR}"
|
||||
|
||||
/* KDE's static shared data directory */
|
||||
#define KDE_SHAREDIR "${KDE4_SHARE_INSTALL_PREFIX}"
|
||||
|
||||
/* X binaries directory */
|
||||
#cmakedefine XBINDIR "${XBINDIR}"
|
||||
|
||||
|
|
|
@ -14,17 +14,40 @@
|
|||
|
||||
#include <QFile>
|
||||
#include <QRegExp>
|
||||
//Added by qt3to4:
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include "config-workspace.h"
|
||||
|
||||
USBDB::USBDB() {
|
||||
QString db = "/usr/share/hwdata/usb.ids"; /* on Fedora */
|
||||
if (!QFile::exists(db))
|
||||
db = KStandardDirs::locate("data", "kcmusb/usb.ids");
|
||||
if (db.isEmpty())
|
||||
return;
|
||||
static const QStringList s_dbpaths = QStringList()
|
||||
<< QLatin1String("/share/hwdata/usb.ids")
|
||||
<< QLatin1String("/local/share/hwdata/usb.ids")
|
||||
<< QLatin1String("/usr/share/hwdata/usb.ids")
|
||||
<< QLatin1String("/usr/local/share/hwdata/usb.ids")
|
||||
<< QLatin1String("/var/lib/usbutils/usb.ids") // Debian
|
||||
<< QLatin1String(KDE_SHAREDIR "/hwdata/usb.ids");
|
||||
|
||||
QString db;
|
||||
foreach (const QString &dbpath, s_dbpaths) {
|
||||
if (QFile::exists(dbpath)) {
|
||||
kDebug() << "Using" << dbpath << "USB database";
|
||||
db = dbpath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (db.isEmpty()) {
|
||||
kDebug() << "Using bundled USB database";
|
||||
db = KStandardDirs::locate("data", "kcmusb/usb.ids");
|
||||
}
|
||||
|
||||
if (db.isEmpty()) {
|
||||
kWarning() << "Could not find USB database";
|
||||
return;
|
||||
}
|
||||
|
||||
QFile f(db);
|
||||
|
||||
|
@ -81,29 +104,30 @@ USBDB::USBDB() {
|
|||
}
|
||||
|
||||
QString USBDB::vendor(int id) {
|
||||
QString s = _ids[QString("%1").arg(id)];
|
||||
if (id != 0) {
|
||||
return s;
|
||||
}
|
||||
return QString();
|
||||
QString s = _ids[QString("%1").arg(id)];
|
||||
if (id != 0) {
|
||||
return s;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString USBDB::device(int vendor, int id) {
|
||||
QString s = _ids[QString("%1-%2").arg(vendor).arg(id)];
|
||||
if ((id != 0) && (vendor != 0))
|
||||
return s;
|
||||
return QString();
|
||||
QString s = _ids[QString("%1-%2").arg(vendor).arg(id)];
|
||||
if ((id != 0) && (vendor != 0)) {
|
||||
return s;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString USBDB::cls(int cls) {
|
||||
return _classes[QString("%1").arg(cls)];
|
||||
return _classes[QString("%1").arg(cls)];
|
||||
}
|
||||
|
||||
QString USBDB::subclass(int cls, int sub) {
|
||||
return _classes[QString("%1-%2").arg(cls).arg(sub)];
|
||||
return _classes[QString("%1-%2").arg(cls).arg(sub)];
|
||||
}
|
||||
|
||||
QString USBDB::protocol(int cls, int sub, int prot) {
|
||||
return _classes[QString("%1-%2-%3").arg(cls).arg(sub).arg(prot)];
|
||||
return _classes[QString("%1-%2-%3").arg(cls).arg(sub).arg(prot)];
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,10 @@ QList<USBDevice*> USBDevice::_devices;
|
|||
USBDB *USBDevice::_db;
|
||||
|
||||
USBDevice::USBDevice() :
|
||||
_bus(0), _level(0), _parent(0), _port(0), _count(0), _device(0), _channels(0), _power(0), _speed(0.0), _bwTotal(0), _bwUsed(0), _bwPercent(0), _bwIntr(0), _bwIso(0), _hasBW(false), _verMajor(0), _verMinor(0), _class(0), _sub(0), _prot(0), _maxPacketSize(0), _configs(0), _vendorID(0),
|
||||
_prodID(0), _revMajor(0), _revMinor(0) {
|
||||
_bus(0), _level(0), _parent(0), _port(0), _count(0), _device(0), _channels(0), _power(0),
|
||||
_speed(0.0), _bwTotal(0), _bwUsed(0), _bwPercent(0), _bwIntr(0), _bwIso(0), _hasBW(false),
|
||||
_verMajor(0), _verMinor(0), _class(0), _sub(0), _prot(0), _maxPacketSize(0), _configs(0),
|
||||
_vendorID(0), _prodID(0), _revMajor(0), _revMinor(0) {
|
||||
_devices.append(this);
|
||||
|
||||
if (!_db) {
|
||||
|
@ -46,7 +48,6 @@ USBDevice::USBDevice() :
|
|||
}
|
||||
|
||||
USBDevice::~USBDevice() {
|
||||
|
||||
}
|
||||
|
||||
static QString catFile(QString fname) {
|
||||
|
|
Loading…
Add table
Reference in a new issue