From 24654ac490e845bb60d1a8e250915614bd8ba9c9 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Tue, 4 Feb 2003 22:38:12 +0000 Subject: - Fixed Titi's newly introduced bugs. Now scannerdrake works at least as under Mandrake 9.0. - Fixed bug of automatic configuration also being done if one opts for manual configuration of an auto-detected scanner. - Made scannerdrake editing the SANE config files instead of replacing them by the config lines from the DB (or emptying them when no config lines are given in the DB). --- perl-install/scanner.pm | 27 ++++++---- perl-install/standalone/scannerdrake | 98 +++++++++++++++++++++++------------- 2 files changed, 81 insertions(+), 44 deletions(-) diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm index f38d59ce9..e5d8bb48d 100755 --- a/perl-install/scanner.pm +++ b/perl-install/scanner.pm @@ -28,39 +28,46 @@ use standalone; use common; use detect_devices; use log; - +use handle_configs; my $_sanedir = "$::prefix/etc/sane.d"; my $_scannerDBdir = "$::prefix$ENV{SHARE_PATH}/ldetect-lst"; -my $scannerDB = readScannerDB("$_scannerDBdir/ScannerDB"); +$scannerDB = readScannerDB("$_scannerDBdir/ScannerDB"); sub confScanner { my ($model, $port) = @_; $port ||= detect_devices::dev_is_devfs() ? "$::prefix/dev/usb/scanner0" : "$::prefix/dev/scanner"; my $a = $scannerDB->{$model}{server}; #print "file:[$a]\t[$model]\t[$port]\n| ", (join "\n| ", @{$scannerDB->{$model}{lines}}),"\n"; - output("$_sanedir/$a.conf", (join "\n", @{$scannerDB->{$model}{lines}})); - substInFile { s/\$DEVICE/$port/ } "$_sanedir/$a.conf"; + my @driverconf = cat_("$_sanedir/$a.conf"); + my @configlines = @{$scannerDB->{$model}{lines}}; + (s/\$DEVICE/$port/) foreach @configlines; + (handle_configs::set_directive(\@driverconf, $_)) foreach @configlines; + output("$_sanedir/$a.conf", @driverconf); add2dll($a); } sub add2dll { return if member($_[0], chomp_(cat_("$_sanedir/dll.conf"))); - append_to_file("$_sanedir/dll.conf", "$_[0]\n"); + my @dllconf = cat_("$_sanedir/dll.conf"); + handle_configs::add_directive(\@dllconf, $_[0]); + output("$_sanedir/dll.conf", @dllconf); } sub detect { my ($i, @res) = 0; foreach (grep { $_->{driver} =~ /scanner/ } detect_devices::usb_probe()) { + use Data::Dumper; + print Dumper ($_); #my ($manufacturer, $model) = split '\|', $_->{description}; #$_->{description} =~ s/Hewlett[-\s_]Packard/HP/; $_->{description} =~ s/Seiko\s+Epson/Epson/i; - push @res, { port => "/dev/usb/scanner$i", val => { #CLASS => 'SCANNER', - #MODEL => $model, - #MANUFACTURER => $manufacturer, + push @res, { port => "/dev/usb/scanner$i", val => { CLASS => 'SCANNER', + MODEL => $model, + MANUFACTURER => $manufacturer, DESCRIPTION => $_->{description}, - #id => $_->{id}, - #vendor => $_->{vendor}, + id => $_->{id}, + vendor => $_->{vendor}, } }; ++$i; } diff --git a/perl-install/standalone/scannerdrake b/perl-install/standalone/scannerdrake index 60f9ec48f..bf7717257 100755 --- a/perl-install/standalone/scannerdrake +++ b/perl-install/standalone/scannerdrake @@ -42,31 +42,42 @@ $wait = undef; (@f) ? auto() : manual(); quit(); +sub removeverticalbar { + my ($s) = @_; + $s =~ s/\|/ /g; + return $s; +} + sub auto { - foreach (@f) { + #use Data::Dumper; + #print Dumper (@f); + foreach (@f) { if (member($_->{val}{DESCRIPTION}, keys %$scanner::scannerDB)) { my $name = $_->{val}{DESCRIPTION}; $name =~ s/\s$//; #some HP entry have a trailing space, i will correct usbtable asap if ($scanner::scannerDB->{$name}{flags}{unsupported}) { - $in->ask_warn('scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", $name)); - return; + $in->ask_warn('scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", removeverticalbar($name))); + next; + } + if ($in->ask_yesorno('scannerdrake',N("%s found on %s, configure it automatically?",removeverticalbar($name),$_->{port}),1)) { + tryConfScanner($name, $_->{port}) or manual(); + } else { + manual(); } - $in->ask_yesorno('scannerdrake',N("%s found on %s, configure it?",$name,$_->{port}),1) or manual(); - tryConfScanner($name, $_->{port}); } else { - $in->ask_yesorno('scannerdrake',N("%s is not in the scanner database, configure it manually?", $_->{val}{DESCRIPTION}),1) and manual(); + $in->ask_yesorno('scannerdrake',N("%s is not in the scanner database, configure it manually?", removeverticalbar($_->{val}{DESCRIPTION})),1) and manual(); } } } sub manual { my $s = $in->ask_from_treelist('scannerdrake', N("Select a scanner"), '|', [' None', keys %$scanner::scannerDB], '') or return; - return if $s eq ' None'; + return 1 if $s eq ' None'; if ($scanner::scannerDB->{$s}{flags}{unsupported}) { - $in->ask_warn('scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", $s)); - return; + $in->ask_warn('scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", removeverticalbar($s))); + return 1; } - tryConfScanner($s); + return tryConfScanner($s); } sub dynamic { @@ -76,10 +87,12 @@ sub dynamic { my $name = $_->{val}{DESCRIPTION}; $name =~ s/\s$//; #some HP entry have a trailing space, i will correct usbtable asap if ($scanner::scannerDB->{$name}{flags}{unsupported}) { - $in->ask_warn('scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", $name)); - return; + $in->ask_warn('scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", removeverticalbar($name))); + next; } - scanner::confScanner($name, $_->{port}) unless $scanner::scannerDB->{$model}{flags}{unsupported}; + scanner::confScanner($name, $_->{port}); + } else { + $in->ask_warn('scannerdrake', N("The %s is not known by this version of scannerdrake.", removeverticalbar($name))); } } } @@ -88,35 +101,52 @@ sub tryConfScanner { # take care if interactive output is needed (unsupported, parallel..) my ($model, $port) = @_; if ($scanner::scannerDB->{$model}{flags}{unsupported}) { - $in->ask_warn('scannerdrake', N("This %s scanner is unsupported", $model)); - return; - } - # if ($scanner::scannerDB->{$model}{driver} =~ /Parport/) { - # $in->ask_warn('scannerdrake', N("This %s scanner uses parallel port, which is unsupported for the moment", $model)); - # return; - # } - if ($scanner::scannerDB->{$model}{driver} =~ /SCSI/) { - #$in->ask_warn('scannerdrake', N("This %s scanner uses parallel port, which is unsupported for the moment", $model)); - #return; + $in->ask_warn('scannerdrake', N("The %s is unsupported", + removeverticalbar($model))); + return 0; } if ($scanner::scannerDB->{$model}{ask} =~ /DEVICE/) { - $port = '/dev/sg0'; + $port = '/dev/usb/scanner0'; $in->ask_from('scannerdrake', - N("Scannerdrake was not able to detect your %s scanner.\nPlease select the device where your scanner is attached", $model), + N("Scannerdrake was not able to detect your %s.\nPlease select the device where your scanner is attached", removeverticalbar($model)), [ - { label => N("choose device"), val => \$port, list => ['/dev/sg0', '/dev/sg1', '/dev/sg2', '/dev/sg3', '/dev/sg4' ], not_edit => 0, sort => 1 }, - ], - ) or manual(); + { label => N("choose device"), + val => \$port, + list => ['/dev/scanner', + '/dev/usb/scanner0', + '/dev/usb/scanner1', + '/dev/usb/scanner2', + 'libusb:001:001', + 'libusb:001:002', + 'libusb:001:003', + 'libusb:001:004', + 'libusb:001:005', + 'libusb:001:006', + 'libusb:001:007', + 'libusb:001:008', + 'libusb:001:009', + 'libusb:001:010', + '/dev/sg0', + '/dev/sg1', + '/dev/sg2', + '/dev/sg3', + '/dev/sg4', + '/dev/parport0', + '/dev/parport1', + '/dev/parport2', + '/dev/pt_drv'], + not_edit => 0, sort => 1 }, + ], + ) or manual(); } - - if ($scanner::scannerDB->{$model}{server} =~ /printerdrake/) { - $in->ask_warn('scannerdrake', N("This %s scanner must be configured by printerdrake.\nYou can launch printerdrake from the Mandrake Control Center in Hardware section.", $model)); - return; + if ($scanner::scannerDB->{$model}{server} =~ /(printerdrake|hpoj)/) { + $in->ask_warn('scannerdrake', N("The %s must be configured by printerdrake.\nYou can launch printerdrake from the Mandrake Control Center in Hardware section.", removeverticalbar($model))); + return 0; } scanner::confScanner($model,$port); $in->ask_warn(N("Congratulations!"), - N("Your %s scanner has been configured.\nYou may now scan documents using ``XSane'' from Multimedia/Graphics in the applications menu.", $model)); - + N("Your %s has been configured.\nYou may now scan documents using \"XSane\" from Multimedia/Graphics in the applications menu.", removeverticalbar($model))); + return 1; } sub quit { -- cgit v1.2.1