summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2002-09-12 03:24:59 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2002-09-12 03:24:59 +0000
commit137dec7aa285845e1f7b37fdf62d8c1812df95a3 (patch)
tree55b0103d12ee366a2a3fb62c9e9261f3e62a8d40
parentf1f8d45f08037952d9d2c90be221ecd86c8cb283 (diff)
downloaddrakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar.gz
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar.bz2
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.tar.xz
drakx-137dec7aa285845e1f7b37fdf62d8c1812df95a3.zip
Made the association of model names obtained by auto-detection and of
the model names in the printer database much more reliable.
-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}) {