summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/detect_devices.pm5
-rw-r--r--perl-install/printerdrake.pm34
2 files changed, 35 insertions, 4 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 8b36f99dc..c60e356c2 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -591,8 +591,13 @@ sub whatUsbport() {
$manufacturer =~ s/Hewlett[-\s_]Packard/HP/;
$manufacturer =~ s/HEWLETT[-\s_]PACKARD/HP/;
}
+ # For HP's multi-function devices the real model name is in the "SKU"
+ # field. So use this field with priority for $model when it exists.
if (($idstr =~ /MDL:([^;]+);/) ||
($idstr =~ /MODEL:([^;]+);/)) {
+ $model = $1 if !$model;
+ }
+ if ($idstr =~ /SKU:([^;]+);/) {
$model = $1;
}
if (($idstr =~ /DES:([^;]+);/) ||
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index e9dc78834..3fe92c9a6 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -1436,12 +1436,14 @@ sub setup_common {
foreach (@autodetected) {
$device eq $_->{port} or next;
if (($_->{val}{MANUFACTURER}) && ($_->{val}{MODEL})) {
- $descr = "$_->{val}{MANUFACTURER} $_->{val}{MODEL}";
+ $descr = "$_->{val}{MANUFACTURER}|$_->{val}{MODEL}";
} else {
$descr = $_->{val}{DESCRIPTION};
+ $descr =~ s/ /\|/;
}
# Clean up the description from noise which makes the best match
# difficult
+ $descr =~ s/Seiko\s+Epson/Epson/;
$descr =~ s/\s+Inc\.//;
$descr =~ s/\s+Corp\.//;
$descr =~ s/\s+SA\.//;
@@ -1452,10 +1454,34 @@ sub setup_common {
$descr =~ s/\s+[Ss]eries//;
$descr =~ s/\s+\(?[Pp]rinter\)?$//;
$printer->{DBENTRY} = "";
- for my $entry (keys(%printer::thedb)) {
- if ($entry =~ m!$descr!i) {
+ # Try to find an exact match, check both whether the detected
+ # make|model is in the make|model of the database entry and vice versa
+ # If there is more than one matching database entry, the longest match
+ # counts.
+ my $matchlength = 0;
+ for my $entry (keys %printer::thedb) {
+ my $dbmakemodel;
+ if ($::expert) {
+ $entry =~ m/^(.*)\|[^\|]*$/;
+ $dbmakemodel = $1;
+ } else {
+ $dbmakemodel = $entry;
+ }
+ next if !$dbmakemodel;
+ $dbmakemodel =~ s/\|/\\\|/;
+ my $searchterm = $descr;
+ $searchterm =~ s/\|/\\\|/;
+ my $lsearchterm = length($searchterm);
+ if (($lsearchterm > $matchlength) &&
+ ($entry =~ m!$searchterm!i)) {
+ $matchlength = $lsearchterm;
+ $printer->{DBENTRY} = $entry;
+ }
+ my $ldbmakemodel = length($dbmakemodel);
+ if (($ldbmakemodel > $matchlength) &&
+ ($descr =~ m!$dbmakemodel!i)) {
+ $matchlength = $ldbmakemodel;
$printer->{DBENTRY} = $entry;
- last;
}
}
if (!$printer->{DBENTRY}) {