diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2003-02-14 23:48:59 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2003-02-14 23:48:59 +0000 |
commit | a7759e59f17339920553a03e31230dbc20c68d1c (patch) | |
tree | 562505c94eda4a269457c659ec59f9862af7146f /perl-install/standalone/scannerdrake | |
parent | 2ec37355a7a644be263e1c35f4afc3d6256a5b96 (diff) | |
download | drakx-a7759e59f17339920553a03e31230dbc20c68d1c.tar drakx-a7759e59f17339920553a03e31230dbc20c68d1c.tar.gz drakx-a7759e59f17339920553a03e31230dbc20c68d1c.tar.bz2 drakx-a7759e59f17339920553a03e31230dbc20c68d1c.tar.xz drakx-a7759e59f17339920553a03e31230dbc20c68d1c.zip |
Improved manual scanner configuration, bug fixes.
Diffstat (limited to 'perl-install/standalone/scannerdrake')
-rwxr-xr-x | perl-install/standalone/scannerdrake | 218 |
1 files changed, 133 insertions, 85 deletions
diff --git a/perl-install/standalone/scannerdrake b/perl-install/standalone/scannerdrake index 99b045148..2901644c0 100755 --- a/perl-install/standalone/scannerdrake +++ b/perl-install/standalone/scannerdrake @@ -74,8 +74,6 @@ sub removeverticalbar { } sub auto { - #use Data::Dumper; - #print Dumper (@f); my $changed = 0; foreach (@f) { if (member($_->{val}{DESCRIPTION}, keys %$scanner::scannerDB)) { @@ -86,26 +84,153 @@ sub auto { next; } if ($in->ask_yesorno('Scannerdrake',N("%s found on %s, configure it automatically?",removeverticalbar($name),$_->{port}),1)) { - $changed ||= (tryConfScanner($name, $_->{port}) or - manual()); + $changed ||= (tryConfScanner($name, $_->{port}, + $_->{val}{vendor}, + $_->{val}{id}) or + manual($_->{port}, $_->{val}{vendor}, + $_->{val}{id}, $name)); } else { - $changed ||= manual(); + $changed ||= manual($_->{port}, $_->{val}{vendor}, + $_->{val}{id}, $name); } } else { - $in->ask_yesorno('Scannerdrake',N("%s is not in the scanner database, configure it manually?", removeverticalbar($_->{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 ($changed ||= + manual($_->{port}, $_->{val}{vendor}, $_->{val}{id}, + $_->{val}{DESCRIPTION})); } } return $changed; } sub manual { - my $s = $in->ask_from_treelist('Scannerdrake', N("Select a scanner"), '|', [' None', keys %$scanner::scannerDB], '') or return 0; + my ($port, $vendor, $product, $name) = @_; + my $s = + $in->ask_from_treelist('Scannerdrake', + N("Select a scanner model") . + if_($port || $name, N(" (")) . + if_($name, N("Detected model: %s", + removeverticalbar($name))) . + if_($port && $name, N(", ")) . + if_($port, N("Port: %s", $port)) . + if_($port || $name, N(")")), + '|', [' None', keys %$scanner::scannerDB], + '') or return 0; return 0 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.", removeverticalbar($s))); return 0; } - return tryConfScanner($s); + return tryConfScanner($s, $port, $vendor, $product); +} + +sub dynamic { + @f = scanner::detect(); + 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.", removeverticalbar($name))); + next; + } + scanner::confScanner($name, $_->{port}, + $_->{val}{vendor}, $_->{val}{id}); + } else { + $in->ask_warn('Scannerdrake', N("The %s is not known by this version of Scannerdrake.", removeverticalbar($name))); + } + } +} + +sub tryConfScanner { + # take care if interactive output is needed (unsupported, parallel..) + my ($model, $port, $vendor, $product) = @_; + if ($scanner::scannerDB->{$model}{flags}{unsupported}) { + $in->ask_warn('Scannerdrake', N("The %s is unsupported", + removeverticalbar($model))); + return 0; + } + if (($scanner::scannerDB->{$model}{ask} =~ /DEVICE/) || (!$port)){ + $port ||= N("Auto-detect available ports"); + $in->ask_from('Scannerdrake', + N("Please select the device where your %s is attached", removeverticalbar($model)) . " " . + N("(Note: Parallel ports cannot be auto-detected)"), + [ + { label => N("choose device"), + val => \$port, + list => [N("Auto-detect available ports"), + '/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', + '/dev/ttyS0', + '/dev/ttyS1', + '/dev/ttyS2'], + not_edit => 0, sort => 0 }, + ], + ) or return 0; + if ($port eq N("Auto-detect available ports")) { + $wait = $in->wait_message(N("Scannerdrake"), + N("Searching for scanners ...")); + my @d = scanner::detect(); + undef $wait; + my @list = map { + $_->{port} . " (" . + removeverticalbar($_->{val}{DESCRIPTION}) . ")"; + } @d; + $port ||= $list[0]; + $in->ask_from('Scannerdrake', + N("Please select the device where your %s is attached", removeverticalbar($model)), + [ + { label => N("choose device"), + val => \$port, + list => \@list, + not_edit => 1, sort => 0 }, + ], + ) or return 0; + $port =~ s/^\s*([^\(\s]*)\s*\(.*$/$1/; + foreach (@d) { + next if $_->{port} ne $port; + $vendor = $_->{val}{vendor}; + $product = $_->{val}{id}; + last; + } + } + } + ($vendor, $product) = scanner::get_usb_ids_for_port($port); + if ($scanner::scannerDB->{$model}{server} =~ /(printerdrake|hpoj)/i) { + $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, $vendor, $product); + $in->ask_warn(N("Congratulations!"), + 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 { + $::isEmbedded ? kill('USR1', $::CCPID) : $in->exit(0); } sub mainwindow { @@ -210,83 +335,6 @@ sub mainwindow { } } -sub dynamic { - @f = scanner::detect(); - 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.", removeverticalbar($name))); - next; - } - scanner::confScanner($name, $_->{port}, - $_->{val}{vendor}, $_->{val}{id}); - } else { - $in->ask_warn('Scannerdrake', N("The %s is not known by this version of Scannerdrake.", removeverticalbar($name))); - } - } -} - -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("The %s is unsupported", - removeverticalbar($model))); - return 0; - } - if (($scanner::scannerDB->{$model}{ask} =~ /DEVICE/) || (!$port)){ - $port = '/dev/usb/scanner0'; - $in->ask_from('Scannerdrake', - N("Please select the device where your %s is attached", removeverticalbar($model)), - [ - { 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', - '/dev/ttyS0', - '/dev/ttyS1', - '/dev/ttyS2'], - not_edit => 0, sort => 0 }, - ], - ) or return 0; - } - if ($scanner::scannerDB->{$model}{server} =~ /(printerdrake|hpoj)/i) { - $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 has been configured.\nYou may now scan documents using \"XSane\" from Multimedia/Graphics in the applications menu.", removeverticalbar($model))); - return 1; -} - -sub quit { - $::isEmbedded ? kill('USR1', $::CCPID) : $in->exit(0); -} - sub makeexportmenues { my @exports = @_; my %menuexports = map { |