summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/scannerdrake
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/scannerdrake')
-rwxr-xr-xperl-install/standalone/scannerdrake213
1 files changed, 125 insertions, 88 deletions
diff --git a/perl-install/standalone/scannerdrake b/perl-install/standalone/scannerdrake
index 09508e280..947c4c086 100755
--- a/perl-install/standalone/scannerdrake
+++ b/perl-install/standalone/scannerdrake
@@ -1,9 +1,8 @@
#!/usr/bin/perl
-# scannerdrake $Id$
-# Yves Duret <yduret at mandrakesoft.com>
-# Till Kamppeter <till at mandrakesoft.com>
-# Copyright (C) 2001-2004 Mandrakesoft
+# Yves Duret
+# Till Kamppeter
+# Copyright (C) 2001-2008 Mandriva
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,10 +28,8 @@ use scanner;
use handle_configs;
use services;
-my $companyname = "Mandrakesoft";
-my $distroname = "Mandrakelinux";
-my $shortdistroname = "Mandrakelinux";
-my $domainname = "mandrakesoft.com";
+my $distroname = "%s";
+my $shortdistroname = "%s";
foreach (@ARGV) {
/^--update-usbtable$/ and do { scanner::updateScannerDBfromUsbtable(); exit() };
@@ -41,21 +38,21 @@ foreach (@ARGV) {
/^--dynamic=(.*)$/ and do { dynamic(); exit() };
}
-$ugtk2::wm_icon = "scannerdrake";
+$ugtk3::wm_icon = "scannerdrake";
my $in = 'interactive'->vnew('su');
if (!files_exist(qw(/usr/bin/scanimage
/etc/sane.d/dll.conf)) ||
(!files_exist(qw(/usr/bin/xsane)) &&
- !files_exist(qw(/usr/bin/kooka)) &&
+ !files_exist(qw(/usr/bin/skanlite)) &&
!$in->do_pkgs->is_installed('scanner-gui'))) {
if (!$in->ask_yesorno(N("Warning"), N("SANE packages need to be installed to use scanners.
Do you want to install the SANE packages?"))) {
- $in->ask_warn("Scannerdrake",
+ $in->ask_warn(N("Warning"),
N("Aborting Scannerdrake."));
exit 0;
}
- if (!$in->do_pkgs->install('sane-backends', 'scanner-gui')) {
+ if (!$in->do_pkgs->install('task-scanning')) {
$in->ask_warn(N("Error"),
N("Could not install the packages needed to set up a scanner with Scannerdrake.") . " " .
N("Scannerdrake will not be started now."));
@@ -63,11 +60,11 @@ Do you want to install the SANE packages?"))) {
}
}
if ($::Manual) { manual(); quit() }
-my $wait = $in->wait_message(N("Scannerdrake"),
+my $wait = $in->wait_message(N("Please wait"),
N("Searching for configured scanners..."));
-my @c = scanner::configured();
+my @c = scanner::configured($in);
$wait = undef;
-$wait = $in->wait_message(N("Scannerdrake"),
+$wait = $in->wait_message(N("Please wait"),
N("Searching for new scanners..."));
my @f = scanner::detect(@c);
$wait = undef;
@@ -75,9 +72,9 @@ my $changed = 0;
@f and $changed = auto();
if ($changed) {
my $_wait =
- $in->wait_message(N("Scannerdrake"),
+ $in->wait_message(N("Please wait"),
N("Re-generating list of configured scanners..."));
- @c = scanner::configured();
+ @c = scanner::configured($in);
}
mainwindow(@c);
quit();
@@ -94,25 +91,25 @@ sub auto() {
my $changed = 0;
foreach (@f) {
my $c = 0;
- if (member($_->{val}{DESCRIPTION}, keys %$scanner::scannerDB)) {
+ if (exists $scanner::scannerDB->{$_->{val}{DESCRIPTION}}) {
my $name = $_->{val}{DESCRIPTION};
$name =~ s/\s$//; # some HP entries 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 %s.", removeverticalbar($name), $distroname));
+ $in->ask_warn(N("Error"), N("The %s is not supported by this version of %s.", removeverticalbar($name), $distroname));
next;
}
- if ($in->ask_yesorno('Scannerdrake', N("%s found on %s, configure it automatically?", removeverticalbar($name), $_->{port}),1)) {
- $c = (tryConfScanner($name, $_->{port},
+ if ($in->ask_yesorno(N("Confirmation"), N("%s found on %s, configure it automatically?", removeverticalbar($name), $_->{port}),1)) {
+ $c = tryConfScanner($name, $_->{port},
$_->{val}{vendor},
$_->{val}{id}) ||
manual($_->{port}, $_->{val}{vendor},
- $_->{val}{id}, $name));
+ $_->{val}{id}, $name);
} else {
$c = manual($_->{port}, $_->{val}{vendor},
$_->{val}{id}, $name);
}
} else {
- $in->ask_yesorno('Scannerdrake',
+ $in->ask_yesorno(N("Confirmation"),
N("%s is not in the scanner database, configure it manually?",
removeverticalbar($_->{val}{DESCRIPTION})),1)
and $c =
@@ -127,19 +124,19 @@ sub auto() {
sub manual {
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],
+ $in->ask_from_treelist(N("Scanner configuration"),
+ ($port && $name ? N("Select a scanner model (Detected model: %s, Port: %s)",
+ removeverticalbar($name), $port)
+ : $name ? N("Select a scanner model (Detected model: %s)", removeverticalbar($name))
+ : $port ? N("Select a scanner model (Port: %s)", $port) : ""
+ ),
+ '|', [' None', map { $_ . if_($scanner::scannerDB->{$_}{flags}{unsupported}, N(" (UNSUPPORTED)")) } keys %$scanner::scannerDB],
'') or return 0;
return 0 if $s eq ' None';
+ my $unsuppstr = quotemeta(N(" (UNSUPPORTED)"));
+ $s =~ s/$unsuppstr$//;
if ($scanner::scannerDB->{$s}{flags}{unsupported}) {
- $in->ask_warn('Scannerdrake', N("The %s is not supported by this version of %s.", removeverticalbar($s), $distroname));
+ $in->ask_warn(N("Error"), N("The %s is not supported under Linux.", removeverticalbar($s)));
return 0;
}
return tryConfScanner($s, $port, $vendor, $product);
@@ -149,10 +146,14 @@ sub dynamic() {
@f = scanner::detect();
my $name;
foreach (@f) {
- if (member($_->{val}{DESCRIPTION}, keys %$scanner::scannerDB)) {
+ if (exists $scanner::scannerDB->{$_->{val}{DESCRIPTION}}) {
$name = $_->{val}{DESCRIPTION};
$name =~ s/\s$//; #some HP entry have a trailing space, i will correct usbtable asap
- next if ($scanner::scannerDB->{$name}{flags}{unsupported});
+ next if $scanner::scannerDB->{$name}{flags}{unsupported};
+ if (my @modules = @{$scanner::scannerDB->{$name}{kernel}}) {
+ modules::load(@modules);
+ modules::append_to_modules_loaded_at_startup_for_all_kernels(@modules);
+ }
scanner::confScanner($name, $_->{port},
$_->{val}{vendor}, $_->{val}{id}, "");
}
@@ -165,7 +166,7 @@ sub installfirmware {
my $choice = N("Do not install firmware file");
while (1) {
# Tell user about firmware installation
- $in->ask_from('Scannerdrake',
+ $in->ask_from(N("Scanner Firmware"),
N("It is possible that your %s needs its firmware to be uploaded everytime when it is turned on.", removeverticalbar($model)) . " " .
N("If this is the case, you can make this be done automatically.") . " " .
N("To do so, you need to supply the firmware file for your scanner so that it can be installed.") . " " .
@@ -191,8 +192,8 @@ sub installfirmware {
return "";
}
# Let user select a firmware file from a floppy, hard disk, ...
- $firmware = $in->ask_file(N("Select firmware file"), "$dir");
- last if !$firmware || (-r $firmware);
+ $firmware = $in->ask_file(N("Select firmware file"), $dir);
+ last if !$firmware || -r $firmware;
$in->ask_warn(N("Error"),
N("The firmware file %s does not exist or is unreadable!",
$firmware));
@@ -208,14 +209,14 @@ sub updatefirmware {
my $firmware;
my @scanners =
map {
- $_->{val}{DESCRIPTION}
+ $_->{val}{DESCRIPTION};
} grep {
- $_->{val}{FIRMWARELINE}
+ $_->{val}{FIRMWARELINE};
} @configured;
my ($scannerchoice, $mediachoice);
while (1) {
# Tell user about firmware installation
- $in->ask_from('Scannerdrake',
+ $in->ask_from(N("Scanner Firmware"),
($#scanners > 0 ?
N("It is possible that your scanners need their firmware to be uploaded everytime when they are turned on.") :
N("It is possible that your %s needs its firmware to be uploaded everytime when it is turned on.", $scanners[0])) . " " .
@@ -250,8 +251,8 @@ sub updatefirmware {
}
# Let user select a firmware file from a floppy, hard disk, ...
$firmware = $in->ask_file(N("Select firmware file for the %s",
- $scannerchoice), "$dir");
- last if !$firmware || (-r $firmware);
+ $scannerchoice), $dir);
+ last if !$firmware || -r $firmware;
$in->ask_warn(N("Error"),
N("The firmware file %s does not exist or is unreadable!",
$firmware));
@@ -272,14 +273,14 @@ sub updatefirmware {
return 0;
}
# Enter the path to the firmware in the appropriate config file
- my $firmwareline =$_->{val}{FIRMWARELINE};
+ my $firmwareline = $_->{val}{FIRMWARELINE};
$firmwareline =~ s/\$FIRMWARE/$firmware/sg;
scanner::setfirmware($backend, $firmwareline);
last;
}
# Success message
- $in->ask_warn('Scannerdrake',
+ $in->ask_warn(N("Information"),
N("The firmware file for your %s was successfully installed.",
$scannerchoice));
@@ -290,17 +291,41 @@ 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",
+ $in->ask_warn(N("Warning"), N("The %s is unsupported",
removeverticalbar($model)));
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 %s Control Center in Hardware section.", removeverticalbar($model), $shortdistroname));
+ if ($scanner::scannerDB->{$model}{server} =~ /(printerdrake|hpoj|hpaio|hplip)/i) {
+ $in->ask_warn(N("Warning"), N("The %s must be configured by system-config-printer.\nYou can launch system-config-printer from the %s Control Center in Hardware section.", removeverticalbar($model), $shortdistroname));
return 0;
}
+ my @modules;
+ if (defined($scanner::scannerDB->{$model}{kernel})) {
+ push @modules, @{$scanner::scannerDB->{$model}{kernel}};
+ } elsif (defined($scanner::scannerDB->{$model}{scsikernel}) &&
+ $scanner::scannerDB->{$model}{driver} =~ /SCSI/i) {
+ push @modules, @{$scanner::scannerDB->{$model}{scsikernel}};
+ } elsif (defined($scanner::scannerDB->{$model}{usbkernel}) &&
+ $scanner::scannerDB->{$model}{driver} =~ /USB/i) {
+ push @modules, @{$scanner::scannerDB->{$model}{usbkernel}};
+ } elsif (defined($scanner::scannerDB->{$model}{parportkernel}) &&
+ $scanner::scannerDB->{$model}{driver} =~ /Parport/i) {
+ push @modules, @{$scanner::scannerDB->{$model}{parportkernel}};
+ }
+ if ($#modules >= 0) {
+ my $wait = $in->wait_message(N("Please wait"),
+ N("Setting up kernel modules..."));
+ foreach my $m (@modules) {
+ eval { modules::load($m) };
+ if (!$@) {
+ modules::append_to_modules_loaded_at_startup_for_all_kernels($m);
+ }
+ }
+ undef $wait;
+ }
if ($scanner::scannerDB->{$model}{ask} =~ /DEVICE/ || !$port) {
$port ||= N("Auto-detect available ports");
- $in->ask_from('Scannerdrake',
+ $in->ask_from(N("Device choice"),
N("Please select the device where your %s is attached", removeverticalbar($model)) . " " .
N("(Note: Parallel ports cannot be auto-detected)"),
[
@@ -337,7 +362,7 @@ sub tryConfScanner {
],
) or return 0;
if ($port eq N("Auto-detect available ports")) {
- $wait = $in->wait_message(N("Scannerdrake"),
+ $wait = $in->wait_message(N("Please wait"),
N("Searching for scanners..."));
my @d = scanner::detect();
undef $wait;
@@ -346,7 +371,7 @@ sub tryConfScanner {
removeverticalbar($_->{val}{DESCRIPTION}) . ")";
} @d;
$port ||= $list[0];
- $in->ask_from('Scannerdrake',
+ $in->ask_from(N("Device choice"),
N("Please select the device where your %s is attached", removeverticalbar($model)),
[
{ label => N("choose device"),
@@ -366,14 +391,32 @@ sub tryConfScanner {
}
($vendor, $product) = scanner::get_usb_ids_for_port($port);
my $firmware;
- if (grep { /FIRMWARELINE/ } @{$scanner::scannerDB->{$model}{lines}} ) {
- $firmware = installfirmware($model,
- $scanner::scannerDB->{$model}{server});
+ my $server = $scanner::scannerDB->{$model}{server};
+ if (any { /FIRMWARELINE/ } @{$scanner::scannerDB->{$model}{lines}}) {
+ $firmware = installfirmware($model, $server);
return 0 if $firmware eq "///";
}
scanner::confScanner($model, $port, $vendor, $product, $firmware);
- $in->ask_warn(N("Congratulations!"),
- N("Your %s has been configured.\nYou may now scan documents using \"XSane\" or \"Kooka\" from Multimedia/Graphics in the applications menu.", removeverticalbar($model)));
+ if ($scanner::scannerDB->{$model}{flags}{manual} == 2) {
+ # MANUALREQUIRED in ScannerDB
+ $in->ask_warn(N("Attention!"),
+ N("Your %s cannot be configured fully automatically.\n\nManual adjustments are required. Please edit the configuration file /etc/sane.d/%s.conf. ", removeverticalbar($model), $server) .
+ N("More info in the driver's manual page. Run the command \"man sane-%s\" to read it.", $server) .
+ "\n\n" .
+ N("After that you may scan documents using \"XSane\" or \"%s\" from Multimedia/Graphics in the applications menu.", "Skanlite"));
+ } elsif ($scanner::scannerDB->{$model}{flags}{manual} == 1) {
+ # MANUAL in ScannerDB
+ $in->ask_warn(N("Attention!"),
+ N("Your %s has been configured, but it is possible that additional manual adjustments are needed to get it to work. ", removeverticalbar($model)) .
+ N("If it does not appear in the list of configured scanners in the main window of Scannerdrake or if it does not work correctly, ") .
+ N("edit the configuration file /etc/sane.d/%s.conf. ", $server) .
+ N("More info in the driver's manual page. Run the command \"man sane-%s\" to read it.", $server) .
+ "\n\n" .
+ N("After that you may scan documents using \"XSane\" or \"%s\" from Multimedia/Graphics in the applications menu.", "Skanlite"));
+ } else {
+ $in->ask_warn(N("Congratulations!"),
+ N("Your %s has been configured.\nYou may now scan documents using \"XSane\" or \"%s\" from Multimedia/Graphics in the applications menu.", removeverticalbar($model), "Skanlite"));
+ }
return 1;
}
@@ -395,11 +438,10 @@ sub mainwindow {
if_($entry, " - $entry\n");
} @configured;
if (@scannerlist) {
- my $main_msg =
- @scannerlist > 1 ?
- N_("The following scanners\n\n%s\nare available on your system.\n") :
- N_("The following scanner\n\n%s\nis available on your system.\n");
- sprintf($main_msg, join('', @scannerlist));
+ my $list = join('', @scannerlist);
+ @scannerlist > 1 ?
+ N("The following scanners\n\n%s\nare available on your system.\n", $list) :
+ N("The following scanner\n\n%s\nis available on your system.\n", $list);
} else {
N("There are no scanners found which are available on your system.\n");
}
@@ -412,7 +454,7 @@ sub mainwindow {
if ($in->ask_from_
(
{
- title => N("Scannerdrake"),
+ title => N("Scanner Management"),
messages => $msg,
ok => "",
cancel => "",
@@ -430,13 +472,13 @@ sub mainwindow {
$buttonclicked = "manualadd";
1;
} },
- ( (grep { $_->{val}{FIRMWARELINE} } @configured) ?
+ ((any { $_->{val}{FIRMWARELINE} } @configured) ?
{ val => N("Install/Update firmware files"),
type => 'button',
clicked_may_quit => sub {
$buttonclicked = "firmware";
1;
- } } : () ),
+ } } : ()),
{ val => N("Scanner sharing"),
type => 'button',
clicked_may_quit => sub {
@@ -456,14 +498,14 @@ sub mainwindow {
if ($buttonclicked eq "autoadd") {
# Do scanner auto-detection
my $wait =
- $in->wait_message(N("Scannerdrake"),
+ $in->wait_message(N("Please wait"),
N("Searching for configured scanners..."));
- @configured = scanner::configured();
+ @configured = scanner::configured($in);
$wait =
- $in->wait_message(N("Scannerdrake"),
+ $in->wait_message(N("Please wait"),
N("Searching for new scanners..."));
my @f = scanner::detect(@configured);
- $wait = undef;
+ undef $wait;
if (@f) {
$changed = auto();
}
@@ -482,9 +524,9 @@ sub mainwindow {
}
if ($changed) {
my $_wait =
- $in->wait_message(N("Scannerdrake"),
+ $in->wait_message(N("Please wait"),
N("Re-generating list of configured scanners..."));
- @configured = scanner::configured();
+ @configured = scanner::configured($in);
}
} else {
# Cancel clicked
@@ -528,10 +570,10 @@ sub sharewindow {
my ($menuimports, $menuimports_inv) =
makeimportmenues(@imports);
# Is saned running?
- my $sanedrunning = services::starts_on_boot("saned");
+ my $sanedrunning = services::starts_on_boot("saned.socket");
my $oldsanedrunning = $sanedrunning;
# Is the "net" SANE backend active
- my $netbackendactive = grep { /^\s*net\s*$/ }
+ my $netbackendactive = find { /^\s*net\s*$/ }
cat_("/etc/sane.d/dll.conf");
my $oldnetbackendactive = $netbackendactive;
# Set this to 1 to tell the caller that the list of locally available
@@ -547,7 +589,7 @@ sub sharewindow {
if ($in->ask_from_
(
{
- title => N("Scannerdrake"),
+ title => N("Scanner Sharing"),
messages => N("Here you can choose whether the scanners connected to this machine should be accessible by remote machines and by which remote machines.") .
N("You can also decide here whether scanners on remote machines should be made available on this machine."),
},
@@ -623,7 +665,7 @@ sub sharewindow {
1;
},
disabled => sub {
- return ($#list < 0);
+ return $#list < 0;
} },
{ val => N("Remove selected host"),
type => 'button',
@@ -632,7 +674,7 @@ sub sharewindow {
1;
},
disabled => sub {
- return ($#list < 0);
+ return $#list < 0;
} },
{ val => N("Done"),
type => 'button',
@@ -773,7 +815,7 @@ sub sharewindow {
1;
},
disabled => sub {
- return ($#list < 0);
+ return $#list < 0;
} },
{ val => N("Remove selected host"),
type => 'button',
@@ -782,7 +824,7 @@ sub sharewindow {
1;
},
disabled => sub {
- return ($#list < 0);
+ return $#list < 0;
} },
{ val => N("Done"),
type => 'button',
@@ -902,16 +944,14 @@ sub sharewindow {
# Turn on/off saned
if ($sanedrunning != $oldsanedrunning) {
if ($sanedrunning) {
- # Make sure saned and xinetd is installed and
- # running
- if (!files_exist('/usr/sbin/xinetd',
- '/usr/sbin/saned')) {
+ # Make sure saned is installed and running
+ if (!files_exist('/usr/sbin/saned')) {
if (!$in->ask_yesorno(N("Warning"), N("saned needs to be installed to share the local scanner(s).
Do you want to install the saned package?"))) {
- $in->ask_warn("Scannerdrake",
+ $in->ask_warn("Warning",
N("Your scanner(s) will not be available on the network."));
- } elsif (!$in->do_pkgs->install('xinetd', 'saned')) {
+ } elsif (!$in->do_pkgs->install('saned')) {
$in->ask_warn(N("Error"),
N("Could not install the packages needed to share your scanner(s).") . " " .
N("Your scanner(s) will not be available on the network."));
@@ -919,14 +959,11 @@ Do you want to install the saned package?"))) {
}
# Start saned and make sure that it gets started on
# every boot
- services::start_service_on_boot("saned");
- services::start_service_on_boot("xinetd");
- services::restart("xinetd");
+ services::enable("saned.socket");
} else {
# Stop saned and make sure that it does not get
# started when booting
- services::do_not_start_service_on_boot("saned");
- services::restart("xinetd");
+ services::disable("saned.socket");
}
}
# Turn on/off "net" SANE backend