Fix hardware class file matching algorithm

Fix overly broad floppy device matching rules
This resolves Bug 2534
(cherry picked from commit fd0de2b581)
pull/16/head
Timothy Pearson 9 years ago committed by Slávek Banko
parent d0b958a1d3
commit bc746bd059

@ -1,6 +1,7 @@
[Conditions] [Conditions]
SUBSYSTEM=block SUBSYSTEM=block
DRIVER=floppy DRIVER=floppy
MatchType=All
[DeviceType] [DeviceType]
GENTYPE=Disk GENTYPE=Disk

@ -1,5 +1,6 @@
[Conditions] [Conditions]
ID_TYPE=floppy ID_TYPE=floppy
MatchType=All
[DeviceType] [DeviceType]
GENTYPE=Disk GENTYPE=Disk

@ -1640,27 +1640,61 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDeviceByExternalRules(udev_
for (cndit = conditionmap.begin(); cndit != conditionmap.end(); ++cndit) { for (cndit = conditionmap.begin(); cndit != conditionmap.end(); ++cndit) {
TQStringList conditionList = TQStringList::split(',', cndit.data(), false); TQStringList conditionList = TQStringList::split(',', cndit.data(), false);
bool atleastonematch = false; bool atleastonematch = false;
for ( TQStringList::Iterator paramit = conditionList.begin(); paramit != conditionList.end(); ++paramit ) { bool allmatch = true;
if (cndit.key() == "VENDOR_ID") { TQString matchtype = rulesFile.readEntry("MATCH_TYPE", "All");
if (device->vendorID() == (*paramit)) { if (conditionList.count() < 1) {
atleastonematch = true; allmatch = false;
}
else {
for ( TQStringList::Iterator paramit = conditionList.begin(); paramit != conditionList.end(); ++paramit ) {
if ((*paramit) == "MatchType") {
continue;
} }
} if (cndit.key() == "VENDOR_ID") {
else if (cndit.key() == "MODEL_ID") { if (device->vendorID() == (*paramit)) {
if (device->modelID() == (*paramit)) { atleastonematch = true;
atleastonematch = true; }
else {
allmatch = false;
}
} }
} else if (cndit.key() == "MODEL_ID") {
else if (cndit.key() == "DRIVER") { if (device->modelID() == (*paramit)) {
if (device->deviceDriver() == (*paramit)) { atleastonematch = true;
atleastonematch = true; }
else {
allmatch = false;
}
}
else if (cndit.key() == "DRIVER") {
if (device->deviceDriver() == (*paramit)) {
atleastonematch = true;
}
else {
allmatch = false;
}
} }
else {
if (readUdevAttribute(dev, cndit.key()) == (*paramit)) {
atleastonematch = true;
}
else {
allmatch = false;
}
}
}
}
if (matchtype == "All") {
if (!allmatch) {
match = false;
} }
else if (readUdevAttribute(dev, cndit.key()) == (*paramit)) { }
atleastonematch = true; else if (matchtype == "Any") {
if (!atleastonematch) {
match = false;
} }
} }
if (!atleastonematch) { else {
match = false; match = false;
} }
} }

Loading…
Cancel
Save