summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/detect.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2005-09-28 12:51:32 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2005-09-28 12:51:32 +0000
commit840b4a2a7b7764542cd9e38bd278a15500db5a7a (patch)
tree2412e10ae9fb555103b3d5c4d416e049c8510454 /perl-install/printer/detect.pm
parentbdcbb43f4fd5ee2f8800081689c17e0ad52250d2 (diff)
downloaddrakx-backup-do-not-use-840b4a2a7b7764542cd9e38bd278a15500db5a7a.tar
drakx-backup-do-not-use-840b4a2a7b7764542cd9e38bd278a15500db5a7a.tar.gz
drakx-backup-do-not-use-840b4a2a7b7764542cd9e38bd278a15500db5a7a.tar.bz2
drakx-backup-do-not-use-840b4a2a7b7764542cd9e38bd278a15500db5a7a.tar.xz
drakx-backup-do-not-use-840b4a2a7b7764542cd9e38bd278a15500db5a7a.zip
- Let parallel HP printers be set up with HPLIP.
- Removed HPOJ support (HPOJ obsolete, now completely replaced by HPLIP). - Warn the user if an HP printer is connected via a port which is not supported by HPLIP. - Fixed printerdrake freezing when choosing a machine as remote CUPS server (for daemon-less client) which does not exist or does not run CUPS. - Let network printer detection also work if the DNS is misconfigured. - Let "Printer options" entry in printer editing menu only disapppear if there are really no options (entry disappeared also for Sagem MF3625 with empty manufacturer name in the PPD). - Fixed raw queue being shown with "driver: PPD" and not "driver: raw". - Do not use "Unknown model" and "Unknown Model", this somtimes broke identifying a print queue as being for an unknown printer. - Do not die if /usr/share/hplip/data/xml/models.xml (HPLIP printer database) is missing, this allows creation of live distros without HPLIP. - Fixed loop of determining the HPLIP device URI for local printers in the "printer::main::start_hplip()" function.
Diffstat (limited to 'perl-install/printer/detect.pm')
-rw-r--r--perl-install/printer/detect.pm33
1 files changed, 22 insertions, 11 deletions
diff --git a/perl-install/printer/detect.pm b/perl-install/printer/detect.pm
index b164595a5..1f6e06977 100644
--- a/perl-install/printer/detect.pm
+++ b/perl-install/printer/detect.pm
@@ -165,7 +165,7 @@ sub whatUsbport() {
# Was there a manufacturer and a model in the string?
if ($manufacturer eq "" || $model eq "") {
$manufacturer = "";
- $model = N("Unknown Model");
+ $model = N("Unknown model");
}
# No description field? Make one out of manufacturer and model.
if ($description eq "") {
@@ -204,12 +204,13 @@ sub whatNetPrinter {
return () if $#portstoscan < 0;
my $portlist = join ",", @portstoscan;
-
+
# Which hosts should be scanned?
- # (Applying nmap to a whole network is very time-consuming, because nmap
- # waits for a certain timeout period on non-existing hosts, so we get a
- # lists of existing hosts by pinging the broadcast addresses for existing
- # hosts and then scanning only them, which is much faster)
+ # (Applying nmap to a whole network is very time-consuming,
+ # because nmap waits for a certain timeout period on non-existing
+ # hosts, so we get a lists of existing hosts by pinging the
+ # broadcast addresses for existing hosts and then scanning only
+ # them, which is much faster)
my @hostips = getIPsInLocalNetworks();
return () if $#hostips < 0;
my $hostlist = join " ", @hostips;
@@ -220,7 +221,7 @@ sub whatNetPrinter {
open F, ($::testing ? "" : "chroot $::prefix/ ") .
qq(/bin/sh -c "export LC_ALL=C; nmap -r -P0 --host_timeout $timeout --initial_rtt_timeout $irtimeout -p $portlist $hostlist" 2> /dev/null |)
or return @res;
- my ($host, $ip, $port, $modelinfo) = ("", "", "", "");
+ my ($host, $ip, $port, $modelinfo, $namechecked) = ("", "", "", "", 0);
while (my $line = <F>) {
chomp $line;
@@ -231,13 +232,23 @@ sub whatNetPrinter {
$ip = $host if !$ip;
$host = $ip if $host eq "";
$port = "";
+ $namechecked = 0;
undef $modelinfo;
} elsif ($line =~ m!^\s*(\d+)/\S+\s+open\s+!i) {
next if $ip eq "";
$port = $1;
-
+
+ # Check integrity of the host name (work around DNS problems
+ # by using IP if host name is broken)
+ if (!$namechecked && ($host ne $ip)) {
+ $namechecked = 1; # Do not check more than once
+ my $packedip = gethostbyname("$host");
+ my ($a,$b,$c,$d) = unpack('C4',$packedip);
+ my $ipfromdns = sprintf("%d.%d.%d.%d", $a, $b, $c, $d);
+ $host = $ip if $ip ne $ipfromdns;
+ }
# Now we have all info for one printer
# Store this auto-detection result in the data structure
@@ -249,7 +260,7 @@ sub whatNetPrinter {
foreach my $share (@shares) {
push @res, { port => "smb://$host/$share->{name}",
val => { CLASS => 'PRINTER',
- MODEL => N("Unknown Model"),
+ MODEL => N("Unknown model"),
MANUFACTURER => "",
DESCRIPTION => $share->{description},
SERIALNUMBER => ""
@@ -484,7 +495,7 @@ sub getSNMPModel {
open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
qq(/bin/sh -c "scli -v 1 -c 'show printer info' $host" 2> /dev/null |) or
return { CLASS => 'PRINTER',
- MODEL => N("Unknown Model"),
+ MODEL => N("Unknown model"),
MANUFACTURER => "",
DESCRIPTION => "",
SERIALNUMBER => ""
@@ -557,7 +568,7 @@ sub getSNMPModel {
}
# We couldn't determine a model
- $model = N("Unknown Model") if $model eq "";
+ $model = N("Unknown model") if $model eq "";
# Remove trailing spaces
$manufacturer =~ s/(\S+)\s+$/$1/;