summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2005-02-16 13:35:35 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2005-02-16 13:35:35 +0000
commit6d2d2c97967b66528d84b1400431d58cccc00a4b (patch)
tree6d33b96d521237ae62ec1986dbb24290f93f4d7a
parent34f248eeebe180e56da780d1c5aa4c662ee652a6 (diff)
downloaddrakx-6d2d2c97967b66528d84b1400431d58cccc00a4b.tar
drakx-6d2d2c97967b66528d84b1400431d58cccc00a4b.tar.gz
drakx-6d2d2c97967b66528d84b1400431d58cccc00a4b.tar.bz2
drakx-6d2d2c97967b66528d84b1400431d58cccc00a4b.tar.xz
drakx-6d2d2c97967b66528d84b1400431d58cccc00a4b.zip
- If a printer is set up with HPLIP and has still an old HPOJ configuration,
it will be automatically removed now.
-rw-r--r--perl-install/printer/main.pm51
-rw-r--r--perl-install/printer/printerdrake.pm15
2 files changed, 64 insertions, 2 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index 6af5aad63..ec6082f21 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -2222,10 +2222,10 @@ sub autodetectionentry_for_uri {
return $p;
}
}
- } elsif ($uri =~ m!^hp:/(usb|par)/!) {
+ } elsif ($uri =~ m!^hp:/(usb|par|net)/!) {
# HP printer (controlled by HPLIP)
my $hplipdevice = $uri;
- $hplipdevice =~ m!^hp:/(usb|par)/(\S+?)(\?serial=(\S+)|)$!;
+ $hplipdevice =~ m!^hp:/(usb|par|net)/(\S+?)(\?serial=(\S+)|)$!;
my $model = $2;
my $serial = $4;
$model =~ s/_/ /g;
@@ -2541,6 +2541,53 @@ sub start_hplip_manual {
return @uris;
}
+sub remove_hpoj_config {
+ my ($device, @autodetected) = @_;
+
+ for my $d (@autodetected) {
+ $device eq $d->{port} or next;
+ my $bus;
+ if ($device =~ /usb/) {
+ $bus = "usb";
+ } elsif ($device =~ /par/ ||
+ $device =~ m!/dev/lp! ||
+ $device =~ /printers/) {
+ $bus = "par";
+ } elsif ($device =~ /socket/) {
+ $bus = "hpjd";
+ }
+ my $path = "$::prefix/etc/ptal";
+ opendir PTALDIR, "$path";
+ while (my $file = readdir(PTALDIR)) {
+ next if $file !~ /^(mlc:|)$bus:/;
+ $file = "$path/$file";
+ if ($bus eq "hpjd") {
+ $device =~ m!^socket://(\S+?)(:\d+|)$!;
+ my $host = $1;
+ if ($file =~ /$host/) {
+ closedir PTALDIR;
+ unlink ($file) or return $file;
+ printer::services::restart("hpoj");
+ return undef;
+ }
+ } else {
+ if ((grep { /$d->{val}{MODEL}/ } chomp_(cat_($file))) &&
+ ((!$d->{val}{SERIALNUMBER}) ||
+ (grep { /$d->{val}{SERIALNUMBER}/ }
+ chomp_(cat_($file))))) {
+ closedir PTALDIR;
+ unlink ($file) or return $file;
+ printer::services::restart("hpoj");
+ return undef;
+ }
+ }
+ }
+ last;
+ }
+ closedir PTALDIR;
+ return undef;
+}
+
sub configure_hpoj {
my ($device, @autodetected) = @_;
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 3e8ab3eda..328593d32 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -2148,6 +2148,21 @@ sub setup_common {
};
}
}
+ # Remove old HPOJ configuration for this device
+ if (-f "/usr/sbin/ptal-mlcd") { # HPOJ installed?
+ if (my $configfile =
+ printer::main::remove_hpoj_config($device, @autodetected)) {
+ if (!$printer->{noninteractive} && !$::noX) {
+ undef $w;
+ local $::isWizard = 0;
+ $in->ask_warn
+ (N("Error"),
+ N("Could not remove your old HPOJ configuration file %s for your %s! ",
+ $configfile, $makemodel) .
+ N("Please remove the file manually and restart HPOJ."));
+ }
+ }
+ }
# Start HPLIP and get device URI
undef $w;
$w = $in->wait_message(