summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/printer.pm159
-rw-r--r--perl-install/printerdrake.pm127
2 files changed, 206 insertions, 80 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 49170e209..c655e3a8a 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -19,6 +19,9 @@ my $FOOMATICCONFDIR = "/etc/foomatic";
#-location of the file containing the default spooler's name
my $FOOMATIC_DEFAULT_SPOOLER = "$FOOMATICCONFDIR/defaultspooler";
+#-Did we already read the subroutines of /usr/sbin/ptal-init?
+my $ptalinitread = 0;
+
%spooler = (
_("CUPS - Common Unix Printing System") => "cups",
_("LPRng - LPR New Generation") => "lprng",
@@ -1456,36 +1459,44 @@ sub configure_hpoj {
my ($device, @autodetected) = @_;
# Make the subroutines of /usr/sbin/ptal-init available
- local *PTALINIT;
- open PTALINIT, "/usr/sbin/ptal-init" || do {
- die "unable to open /usr/sbin/ptal-init";
- };
- my @ptalinitfunctions; # subroutine definitions in /usr/sbin/ptal-init
- while(<PTALINIT>) {
- if (m!sub main!) {
- last;
- } elsif (m!^[^\#]!) {
- push (@ptalinitfunctions, $_);
+ # It's only necessary to read it at the first call of this subroutine,
+ # the subroutine definitions stay valid after leaving this subroutine.
+ if (!$ptalinitread) {
+ local *PTALINIT;
+ open PTALINIT, "/usr/sbin/ptal-init" || do {
+ die "unable to open /usr/sbin/ptal-init";
+ };
+ my @ptalinitfunctions; # subroutine definitions in /usr/sbin/ptal-init
+ while(<PTALINIT>) {
+ if (m!sub main!) {
+ last;
+ } elsif (m!^[^\#]!) {
+ push (@ptalinitfunctions, $_);
+ }
}
+ close PTALINIT;
+ eval "@ptalinitfunctions
+ sub getDevnames {
+ return (%devnames)
+ }
+ sub getConfigInfo {
+ return (%configInfo)
+ }";
+ $ptalinitread = 1;
}
- close PTALINIT;
- eval "@ptalinitfunctions
- sub getDevnames {
- return (%devnames)
- }
- sub getConfigInfo {
- return (%configInfo)
- }";
# Read the HPOJ config file and check whether this device is already
# configured
- setupVariables();
- readDeviceInfo();
+ setupVariables ();
+ readDeviceInfo ();
# Get the model ID as auto-detected
$device =~ m!^/dev/\S*lp(\d+)$!;
my $model = $1;
+ my $model_long = $1;
my $serialnumber = "";
+ my $serialnumber_long = "";
+ my $cardreader = 0;
my $device_ok = 1;
my $bus;
my $address_arg = "";
@@ -1505,7 +1516,6 @@ sub configure_hpoj {
$devdata = $_;
$model = $_->{val}{MODEL};
$serialnumber = $_->{val}{SERIALNUMBER};
- undef $_->{val}{CARDREADER};
# Check if the device is really an HP multi-function device
stop_service("hpoj");
run_program::rooted($prefix,
@@ -1518,8 +1528,18 @@ sub configure_hpoj {
close F;
if ($devid) {
$device_ok = 1;
- if (cardReaderDetected("mlc:$bus:probe")) {
- $_->{val}{CARDREADER} = 1;
+ if (open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . "/usr/bin/ptal-devid mlc:$bus:probe -long -mdl 2>/dev/null |") {
+ $model_long = join("", <F>);
+ close F;
+ chomp $model_long;
+ }
+ if (open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . "/usr/bin/ptal-devid mlc:$bus:probe -long -sern 2>/dev/null |") {
+ $serialnumber_long = join("", <F>);
+ close F;
+ chomp $serialnumber_long;
+ }
+ if (cardReaderDetected ("mlc:$bus:probe")) {
+ $cardreader = 1;
}
}
}
@@ -1536,32 +1556,29 @@ sub configure_hpoj {
}
# No, it is not an HP multi-function device.
return "" if (!$device_ok);
- #$device = "/dev/usb/lp1"; $model = "DeskJet 990C";
-
- # Determine the ptal device name
- my $ptaldevice = lookupDevname("mlc:$bus:", $model, $serialnumber,
- $base_address);
-
+ # Determine the ptal device name from already existing config files
+ my $ptaldevice = lookupDevname ("mlc:$bus:", $model_long,
+ $serialnumber_long, $base_address);
# It's all done for us, the device is already configured
return $ptaldevice if defined($ptaldevice);
- # Determine the ptal name for the device
+ # Determine the ptal name for a new device
$ptaldevice = $model;
$ptaldevice =~ s![\s/]+!_!g;
$ptaldevice = "mlc:$bus:$ptaldevice";
# Delete any old/conflicting devices
- &deleteDevice($ptaldevice);
+ deleteDevice ($ptaldevice);
if ($bus eq "par") {
while (1) {
- my $oldDevname=&lookupDevname("mlc:par:",undef,undef,
+ my $oldDevname = lookupDevname ("mlc:par:",undef,undef,
$base_address);
if (!defined($oldDevname)) {
last;
}
- &deleteDevice($oldDevname);
+ deleteDevice ($oldDevname);
}
}
@@ -1594,7 +1611,7 @@ sub configure_hpoj {
"init.version=1\n";
# Write model string.
- if ($model !~ /\S/) {
+ if ($model_long !~ /\S/) {
print CONFIG
"\n".
"# \"printerdrake\" couldn't read the model but added this device anyway:\n".
@@ -1612,10 +1629,10 @@ sub configure_hpoj {
}
}
print CONFIG
- "init.mlcd.append+=-devidmatch \"$model\"\n";
+ "init.mlcd.append+=-devidmatch \"$model_long\"\n";
# Write serial-number string.
- if ($serialnumber!~/\S/) {
+ if ($serialnumber_long!~/\S/) {
print CONFIG
"\n".
"# The device's serial number is unknown.\n".
@@ -1631,7 +1648,7 @@ sub configure_hpoj {
}
}
print CONFIG
- "init.mlcd.append+=-devidmatch \"$serialnumber\"\n";
+ "init.mlcd.append+=-devidmatch \"$serialnumber_long\"\n";
if ($bus=~/^[pu]/) {
print CONFIG
@@ -1676,7 +1693,7 @@ sub configure_hpoj {
"# If you need to pass any additional command-line options to ptal-printd,\n".
"# then add them to the following line and uncomment the line:\n".
"# init.printd.append+=\n";
- if (defined($_->{val}{CARDREADER})) {
+ if ($cardreader) {
print CONFIG
"\n".
"# Uncomment the following line to enable ptal-photod for this device:\n".
@@ -1688,7 +1705,7 @@ sub configure_hpoj {
"init.photod.append+=-maxaltports 26\n";
}
close(CONFIG);
- readOneDevice($ptaldevice);
+ readOneDevice ($ptaldevice);
# Restart HPOJ
restart_service("hpoj");
@@ -1716,8 +1733,6 @@ sub parport_addr{
}
sub config_sane {
- my ($ptaldevice) = @_;
-
# Add HPOJ backend to /etc/sane.d/dll.conf if needed (no individual
# config file /etc/sane.d/hpoj.conf necessary, the HPOJ driver finds the
# scanner automatically)
@@ -1729,6 +1744,68 @@ sub config_sane {
close F;
}
+sub config_photocard {
+
+ # Add definitions for the drives p:. q:, r:, and s: to /etc/mtools.conf
+ my $mtoolsconf = join("", cat_("$prefix/etc/mtools.conf"));
+ return if $mtoolsconf =~ m/^\s*drive\s+p:/m;
+ my $mtoolsconf_append = "
+# Drive definitions added for the photo card readers in HP multi-function
+# devices driven by HPOJ
+drive p: file=\":0\" remote
+drive q: file=\":1\" remote
+drive r: file=\":2\" remote
+drive s: file=\":3\" remote
+# This turns off some file system integrity checks of mtools, it is needed
+# for some photo cards.
+mtools_skip_check=1
+";
+ open F, ">> $prefix/etc/mtools.conf" or
+ die "can't write mtools config in /etc/mtools.conf: $!";
+ print F $mtoolsconf_append;
+ close F;
+
+ # Generate a config file for the graphical mtools frontend MToolsFM or
+ # modify the existing one
+ my $mtoolsfmconf;
+ if (-f "$prefix/etc/mtoolsfm.conf") {
+ open F, "< $prefix/etc/mtoolsfm.conf" or
+ die "can't read MToolsFM config in $prefix/etc/mtoolsfm.conf: $!";
+ $mtoolsfmconf = join("", <F>);
+ close F;
+ $mtoolsfmconf =~ m/^\s*DRIVES\s*=\s*\"([A-Za-z ]*)\"/m;
+ my $alloweddrives = lc($1);
+ foreach my $letter ( "p", "q", "r", "s" ) {
+ if ($alloweddrives !~ /$letter/) {
+ $alloweddrives .= $letter;
+ }
+ }
+ $mtoolsfmconf =~ s/^\s*DRIVES\s*=\s*\"[A-Za-z ]*\"/DRIVES=\"$alloweddrives\"/m;
+ $mtoolsfmconf =~ s/^\s*LEFTDRIVE\s*=\s*\"[^\"]*\"/LEFTDRIVE=\"p\"/m;
+ } else {
+ $mtoolsfmconf = "\# MToolsFM config file. comments start with a hash sign.
+\#
+\# This variable sets the allowed driveletters (all lowercase). Example:
+\# DRIVES=\"ab\"
+DRIVES=\"apqrs\"
+\#
+\# This variable sets the driveletter upon startup in the left window.
+\# An empty string or space is for the hardisk. Example:
+\# LEFTDRIVE=\"a\"
+LEFTDRIVE=\"p\"
+\#
+\# This variable sets the driveletter upon startup in the right window.
+\# An empty string or space is for the hardisk. Example:
+\# RIGHTDRIVE=\"a\"
+RIGHTDRIVE=\" \"
+";
+ }
+ open F, "> $prefix/etc/mtoolsfm.conf" or
+ die "can't write mtools config in /etc/mtools.conf: $!";
+ print F $mtoolsfmconf;
+ close F;
+}
+
# ------------------------------------------------------------------
#
# Configuration of printers in Applications
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index 86541ffe1..866812467 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -460,12 +460,11 @@ _(" (Parallel Ports: /dev/lp0, /dev/lp1, ..., equivalent to LPT1:, LPT2:, ..., 1
if (!$do_auto_detect) {
local $::isWizard = 0;
$isHPOJ = $in->ask_yesorno(_("Local Printer"),
- _("Is your printer a multi-function device from HP (OfficeJet, PSC, LaserJet 1100/1200/1220/3200/3300 with scanner), an HP PhotoSmart P100 or 1315 or an HP LaserJet 2200?"), 0);
+ _("Is your printer a multi-function device from HP (OfficeJet, PSC, LaserJet 1100/1200/1220/3200/3300 with scanner), an HP PhotoSmart or an HP LaserJet 2200?"), 0);
}
if (($menuchoice =~ /HP\s+OfficeJet/i) ||
($menuchoice =~ /HP\s+PSC/i) ||
- ($menuchoice =~ /HP\s+PhotoSmart\s+P?\s*100\D/i) ||
- ($menuchoice =~ /HP\s+PhotoSmart\s+P?\s*1315/i) ||
+ ($menuchoice =~ /HP\s+PhotoSmart/i) ||
($menuchoice =~ /HP\s+LaserJet\s+1100/i) ||
($menuchoice =~ /HP\s+LaserJet\s+1200/i) ||
($menuchoice =~ /HP\s+LaserJet\s+1220/i) ||
@@ -476,9 +475,10 @@ _(" (Parallel Ports: /dev/lp0, /dev/lp1, ..., equivalent to LPT1:, LPT2:, ..., 1
# Install HPOJ package
if ((!$::testing) &&
(!printer::files_exist((qw(/usr/sbin/ptal-mlcd
- /etc/ptal-start.conf))))) {
+ /usr/sbin/ptal-init
+ /usr/bin/xojpanel))))) {
my $w = $in->wait_message('', _("Installing HPOJ package..."));
- $in->do_pkgs->install('hpoj');
+ $in->do_pkgs->install('hpoj', 'xojpanel');
}
# Configure and start HPOJ
my $w = $in->wait_message
@@ -487,34 +487,60 @@ _(" (Parallel Ports: /dev/lp0, /dev/lp1, ..., equivalent to LPT1:, LPT2:, ..., 1
if ($ptaldevice) {
# Configure scanning with SANE on the MF device
- if (($menuchoice =~ /HP\s+OfficeJet\s+[KVRGPD]/i) ||
- ($menuchoice =~ /HP\s+PSC\s+[579]/i)) {
+ if (($menuchoice !~ /HP\s+PhotoSmart/i) &&
+ ($menuchoice !~ /HP\s+LaserJet\s+2200/i)) {
# Install SANE
if ((!$::testing) &&
(!printer::files_exist((qw(/usr/bin/scanimage
/usr/bin/xscanimage
/usr/bin/xsane
- /etc/sane.d/dll.conf),
+ /etc/sane.d/dll.conf
+ /usr/lib/libsane-hpoj.so.1),
(printer::files_exist
('/usr/bin/gimp') ?
'/usr/bin/xsane-gimp' :
()))))) {
my $w = $in->wait_message
- ('', _("Installing SANE package..."));
+ ('', _("Installing SANE packages..."));
$in->do_pkgs->install('sane-backends', 'sane-frontends',
- 'xsane',
+ 'xsane', 'libsane-hpoj0',
if_($in->do_pkgs->is_installed
('gimp'),'xsane-gimp'));
}
- # Configure the HP SANE backend
- printer::config_sane($ptaldevice);
+ # Configure the HPOJ SANE backend
+ printer::config_sane();
}
+ # Configure photo card access with mtools and MToolsFM
+ if (($menuchoice =~ /HP\s+PhotoSmart/i) ||
+ ($menuchoice =~ /HP\s+PSC\s*9[05]0/i) ||
+ ($menuchoice =~ /HP\s+OfficeJet\s+D\s*1[45]5/i)) {
+ # Install mtools and MToolsFM
+ if ((!$::testing) &&
+ (!printer::files_exist(qw(/usr/bin/mdir
+ /usr/bin/mcopy
+ /usr/bin/MToolsFM
+ )))) {
+ my $w = $in->wait_message
+ ('', _("Installing mtools packages..."));
+ $in->do_pkgs->install('mtools', 'MToolsFM');
+ }
+ # Configure mtools/MToolsFM for photo card access
+ printer::config_photocard();
+ }
+
+ my $text = "";
# Inform user about how to scan with his MF device
- my $text = scanner_help($menuchoice, "ptal:/$ptaldevice");
+ $text = scanner_help($menuchoice, "ptal:/$ptaldevice");
if ($text) {
$in->ask_warn(_("Scanning on your HP multi-function device"),
$text);
}
+ # Inform user about how to access photo cards with his MF device
+ $text = photocard_help($menuchoice, "ptal:/$ptaldevice");
+ if ($text) {
+ $in->ask_warn(_("Photo memory card access on your HP multi-function device"),
+ $text);
+ }
# make the DeviceURI from $ptaldevice.
$printer->{currentqueue}{connect} = "ptal:/" . $ptaldevice;
} else {
@@ -1658,6 +1684,7 @@ sub printer_help {
my $raw = 0;
my $cupsremote = 0;
my $scanning = "";
+ my $photocard = "";
if ($printer->{configured}{$queue}) {
if (($printer->{configured}{$queue}{queuedata}{model} eq
_("Unknown model")) ||
@@ -1673,6 +1700,14 @@ sub printer_help {
if ($scanning) {
$scanning = "\n\n$scanning\n\n";
}
+ # Information about photo card access with HP's multi-function devices
+ $photocard = photocard_help
+ ($printer->{configured}{$queue}{queuedata}{make} . " " .
+ $printer->{configured}{$queue}{queuedata}{model},
+ $printer->{configured}{$queue}{queuedata}{connect});
+ if ($photocard) {
+ $photocard = "\n\n$photocard\n\n";
+ }
} else {
$cupsremote = 1;
}
@@ -1688,12 +1723,13 @@ _("These commands you can also use in the \"Printing command\" field of the prin
_("
The \"%s\" command also allows to modify the option settings for a particular printing job. Simply add the desired settings to the command line, e. g. \"%s <file>\". ", "lpr", ($queue ne $default ? "lpr -P $queue -o option=setting -o switch" : "lpr -o option=setting -o switch")) .
(!$cupsremote ?
- _("To know about the options available for the current printer read either the list shown below or click on the \"Print option list\" button.%s
+ _("To know about the options available for the current printer read either the list shown below or click on the \"Print option list\" button.%s%s
-", $scanning) . printer::lphelp_output($printer) : $scanning .
+", $scanning, $photocard) . printer::lphelp_output($printer) :
+ $scanning . $photocard .
_("Here is a list of the available printing options for the current printer:
-") . printer::lphelp_output($printer)) : $scanning);
+") . printer::lphelp_output($printer)) : $scanning . $photocard);
} elsif ($spooler eq "lprng") {
$dialogtext =
_("To print a file from the command line (terminal window) use the command \"%s <file>\".
@@ -1703,7 +1739,7 @@ _("This command you can also use in the \"Printing command\" field of the printi
(!$raw ?
_("
The \"%s\" command also allows to modify the option settings for a particular printing job. Simply add the desired settings to the command line, e. g. \"%s <file>\". ", "lpr", ($queue ne $default ? "lpr -P $queue -Z option=setting -Z switch" : "lpr -Z option=setting -Z switch")) .
-_("To get a list of the options available for the current printer click on the \"Print option list\" button." . $scanning) : $scanning);
+_("To get a list of the options available for the current printer click on the \"Print option list\" button." . $scanning . $photocard) : $scanning . $photocard);
} elsif ($spooler eq "lpd") {
$dialogtext =
_("To print a file from the command line (terminal window) use the command \"%s <file>\".
@@ -1713,7 +1749,7 @@ _("This command you can also use in the \"Printing command\" field of the printi
(!$raw ?
_("
The \"%s\" command also allows to modify the option settings for a particular printing job. Simply add the desired settings to the command line, e. g. \"%s <file>\". ", "lpr", ($queue ne $default ? "lpr -P $queue -o option=setting -o switch" : "lpr -o option=setting -o switch")) .
-_("To get a list of the options available for the current printer click on the \"Print option list\" button." . $scanning) : $scanning);
+_("To get a list of the options available for the current printer click on the \"Print option list\" button." . $scanning . $photocard) : $scanning . $photocard);
} elsif ($spooler eq "pdq") {
$dialogtext =
_("To print a file from the command line (terminal window) use the command \"%s <file>\" or \"%s <file>\".
@@ -1727,18 +1763,23 @@ If you are using KDE as desktop environment you have a \"panic button\", an icon
_("
The \"%s\" and \"%s\" commands also allow to modify the option settings for a particular printing job. Simply add the desired settings to the command line, e. g. \"%s <file>\".
", "pdq", "lpr", ($queue ne $default ? "pdq -P $queue -aoption=setting -oswitch" : "pdq -aoption=setting -oswitch")) .
-_("To know about the options available for the current printer read either the list shown below or click on the \"Print option list\" button.%s
-
-", $scanning) . printer::pdqhelp_output($printer) : $scanning);
- }
+_("To know about the options available for the current printer read either the list shown below or click on the \"Print option list\" button.%s%s
+
+", $scanning, $photocard) . printer::pdqhelp_output($printer) :
+ $scanning . $photocard);
+ }
+ my $windowtitle = ($scanning ?
+ ($photocard ?
+ _("Printing/Scanning/Photo Cards on \"%s\"", $queue) :
+ _("Printing/Scanning on \"%s\"", $queue)) :
+ ($photocard ?
+ _("Printing/Photo Card Access on \"%s\"", $queue) :
+ _("Printing on the printer \"%s\"", $queue)));
if (!$raw && !$cupsremote) {
my $choice;
while ($choice ne _("Close")) {
$choice = $in->ask_from_list_
- (($scanning ?
- _("Printing/Scanning on \"%s\"", $queue) :
- _("Printing on the printer \"%s\"", $queue)),
- $dialogtext,
+ ($windowtitle, $dialogtext,
[ _("Print option list"), _("Close") ],
_("Close"));
if ($choice ne _("Close")) {
@@ -1747,10 +1788,7 @@ _("To know about the options available for the current printer read either the l
}
}
} else {
- $in->ask_warn(($scanning ?
- _("Printing/Scanning on \"%s\"", $queue) :
- _("Printing on the printer \"%s\"", $queue)),
- $dialogtext);
+ $in->ask_warn($windowtitle, $dialogtext);
}
}
@@ -1758,21 +1796,32 @@ sub scanner_help {
my ($makemodel, $deviceuri) = @_;
if ($deviceuri =~ m!^ptal:/(.*)$!) {
my $ptaldevice = $1;
- if (($makemodel =~ /HP\s+OfficeJet\s+[KVRGPD]/i) ||
- ($makemodel =~ /HP\s+PSC\s+[579]/i)) {
- # SANE-driven models
- return _("Your HP multi-function device was configured automatically to be able to scan. Now you can scan with \"scanimage\" (\"scanimage -d hp:%s\" to specify the scanner when you have more than one) from the command line or with the graphical interfaces \"xscanimage\" or \"xsane\". If you are using the GIMP, you can also scan by choosing the appropriate point in the \"File\"/\"Acquire\" menu. Call also \"man scanimage\" and \"man sane-hp\" on the command line to get more information.
+ if (($makemodel !~ /HP\s+PhotoSmart/i) &&
+ ($makemodel !~ /HP\s+LaserJet\s+2200/i)) {
+ # Models with built-in scanner
+ return _("Your HP multi-function device was configured automatically to be able to scan. Now you can scan with \"scanimage\" (\"scanimage -d hp:%s\" to specify the scanner when you have more than one) from the command line or with the graphical interfaces \"xscanimage\" or \"xsane\". If you are using the GIMP, you can also scan by choosing the appropriate point in the \"File\"/\"Acquire\" menu. Call also \"man scanimage\" on the command line to get more information.
Do not use \"scannerdrake\" for this device!",
$ptaldevice);
- } elsif (($makemodel !~ /HP\s+PhotoSmart/i) &&
- ($makemodel !~ /HP\s+LaserJet\s+2200/i)) {
- # "ptal-hp"-driven models
- return _("Your HP multi-function device was configured automatically to be able to scan. Now you can scan from the command line with \"ptal-hp %s scan ...\". Scanning via a graphical interface or from the GIMP is not supported yet for your device. More information you will find in the \"/usr/share/doc/hpoj-0.8/ptal-hp-scan.html\" file on your system. If you have an HP LaserJet 1100 or 1200 you can only scan when you have the scanner option installed.
+ } else {
+ # Scanner-less models
+ return "";
+ }
+ }
+}
-Do not use \"scannerdrake\" for this device!",
+sub photocard_help {
+ my ($makemodel, $deviceuri) = @_;
+ if ($deviceuri =~ m!^ptal:/(.*)$!) {
+ my $ptaldevice = $1;
+ if (($makemodel =~ /HP\s+PhotoSmart/i) ||
+ ($makemodel =~ /HP\s+PSC\s*9[05]0/i) ||
+ ($makemodel =~ /HP\s+OfficeJet\s+D\s*1[45]5/i)) {
+ # Models with built-in photo card drives
+ return _("Your HP printer was configured automatically to give you access to the photo card drives from your PC. Now you can access your photo cards using the graphical program \"MtoolsFM\" (Menu: \"Applications\" -> \"File tools\" -> \"MTools File Manager\") or the command line utilities \"mtools\" (enter \"man mtools\" on the command line for more info). You find the card's file system under the drive letter \"p:\", or subsequent drive letters when you have more than one HP printer with photo card drives. In \"MtoolsFM\" you can switch between drive letters with the field at the upper-right corners of the file lists.",
$ptaldevice);
} else {
+ # Photo-card-drive-less models
return "";
}
}