summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-09-30 13:33:19 -0500
committerSlávek Banko <slavek.banko@axis.cz>2015-10-02 02:51:41 +0200
commitbc746bd059507970722f7a161bd2146338f0f041 (patch)
tree2f1b41b2370b02100d2a5c142e94bc2853d86d09 /tdecore/tdehw
parentd0b958a1d31599c43537ad42c2048e1ed674eb10 (diff)
downloadtdelibs-bc746bd059507970722f7a161bd2146338f0f041.tar.gz
tdelibs-bc746bd059507970722f7a161bd2146338f0f041.zip
Fix hardware class file matching algorithm
Fix overly broad floppy device matching rules This resolves Bug 2534 (cherry picked from commit fd0de2b581ab3f3bab7bc540d8348f994464723f)
Diffstat (limited to 'tdecore/tdehw')
-rw-r--r--tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass1
-rw-r--r--tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass1
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp64
3 files changed, 51 insertions, 15 deletions
diff --git a/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass b/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass
index b3ccab66c..54368d4ea 100644
--- a/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass
+++ b/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass
@@ -1,6 +1,7 @@
[Conditions]
SUBSYSTEM=block
DRIVER=floppy
+MatchType=All
[DeviceType]
GENTYPE=Disk
diff --git a/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass b/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass
index 6c76d3c85..07b2e43da 100644
--- a/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass
+++ b/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass
@@ -1,5 +1,6 @@
[Conditions]
ID_TYPE=floppy
+MatchType=All
[DeviceType]
GENTYPE=Disk
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index b0162f6fe..62fd6a427 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -1640,27 +1640,61 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDeviceByExternalRules(udev_
for (cndit = conditionmap.begin(); cndit != conditionmap.end(); ++cndit) {
TQStringList conditionList = TQStringList::split(',', cndit.data(), false);
bool atleastonematch = false;
- for ( TQStringList::Iterator paramit = conditionList.begin(); paramit != conditionList.end(); ++paramit ) {
- if (cndit.key() == "VENDOR_ID") {
- if (device->vendorID() == (*paramit)) {
- atleastonematch = true;
+ bool allmatch = true;
+ TQString matchtype = rulesFile.readEntry("MATCH_TYPE", "All");
+ if (conditionList.count() < 1) {
+ allmatch = false;
+ }
+ else {
+ for ( TQStringList::Iterator paramit = conditionList.begin(); paramit != conditionList.end(); ++paramit ) {
+ if ((*paramit) == "MatchType") {
+ continue;
}
- }
- else if (cndit.key() == "MODEL_ID") {
- if (device->modelID() == (*paramit)) {
- atleastonematch = true;
+ if (cndit.key() == "VENDOR_ID") {
+ if (device->vendorID() == (*paramit)) {
+ atleastonematch = true;
+ }
+ else {
+ allmatch = false;
+ }
}
- }
- else if (cndit.key() == "DRIVER") {
- if (device->deviceDriver() == (*paramit)) {
- atleastonematch = true;
+ else if (cndit.key() == "MODEL_ID") {
+ if (device->modelID() == (*paramit)) {
+ 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;
}
}