diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-09-30 13:33:19 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-09-30 13:33:19 -0500 |
commit | fd0de2b581ab3f3bab7bc540d8348f994464723f (patch) | |
tree | 26c9616b48f9a410f9e9ecb07ff4a31b9147b942 /tdecore/tdehw/tdehardwaredevices.cpp | |
parent | 70526c5a3e76b42b242499cb57c051696bcee5eb (diff) | |
download | tdelibs-fd0de2b581ab3f3bab7bc540d8348f994464723f.tar.gz tdelibs-fd0de2b581ab3f3bab7bc540d8348f994464723f.zip |
Fix hardware class file matching algorithm
Fix overly broad floppy device matching rules
This resolves Bug 2534
Diffstat (limited to 'tdecore/tdehw/tdehardwaredevices.cpp')
-rw-r--r-- | tdecore/tdehw/tdehardwaredevices.cpp | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp index 3c08cfcda..bb1318a39 100644 --- a/tdecore/tdehw/tdehardwaredevices.cpp +++ b/tdecore/tdehw/tdehardwaredevices.cpp @@ -1656,27 +1656,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; } } |