From 657b601f8818b63e63d45d80e6e2e78b6a98dbb0 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Tue, 30 Aug 2005 23:46:11 +0000 Subject: - Support for HPLIP URIs with "?device=...", possible fix for bug #18041 and bug #18053. --- perl-install/printer/main.pm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'perl-install') diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index a0ec64f84..cf70a6461 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -2443,9 +2443,15 @@ sub autodetectionentry_for_uri { } elsif ($uri =~ m!^hp:/(usb|par|net)/!) { # HP printer (controlled by HPLIP) my $hplipdevice = $uri; - $hplipdevice =~ m!^hp:/(usb|par|net)/(\S+?)(\?serial=(\S+)|)$!; + $hplipdevice =~ m!^hp:/(usb|par|net)/(\S+?)(\?(serial|device)=(\S+)|)$!; my $model = $2; - my $serial = $4; + my $serial = undef; + my $device = undef; + if ($4 eq 'serial') { + $serial = $5; + } elsif ($4 eq 'device') { + $device = $5; + } $model =~ s/_/ /g; foreach my $p (@autodetected) { next if !$p->{val}{MODEL}; @@ -2459,6 +2465,7 @@ sub autodetectionentry_for_uri { next if ($serial && !$p->{val}{SERIALNUMBER}) || (!$serial && $p->{val}{SERIALNUMBER}) || (uc($serial) ne uc($p->{val}{SERIALNUMBER})); + next if $device && ($device ne $p->{port}); return $p; } } elsif ($uri =~ m!^ptal://?mlc:!) { @@ -2754,14 +2761,18 @@ sub start_hplip { '/bin/sh -c "export LC_ALL=C; /usr/lib/cups/backend/hp" |') or die 'Could not run "/usr/lib/cups/backend/hp"!'; while (my $line = <$F>) { - if (($line =~ m!^direct\s+(hp:/$bus/(\S+)\?serial=(\S+))\s+!) || + if (($line =~ m!^direct\s+(hp:/$bus/(\S+?)\?serial=(\S+))\s+!) || + ($line =~ m!^direct\s+(hp:/$bus/(\S+?)\?device=()(\S+))\s+!) || ($line =~ m!^direct\s+(hp:/$bus/(\S+))\s+!)) { my $uri = $1; my $modelstr = $2; my $serial = $3; + my $devicestr = $4; if ((uc($modelstr) eq uc($hplipentry->{model})) && (!$serial || - (uc($serial) eq uc($a->{val}{SERIALNUMBER})))) { + (uc($serial) eq uc($a->{val}{SERIALNUMBER}))) && + (!$devicestr || + ($devicestr eq $device))) { close $F; return $uri; } -- cgit v1.2.1