summaryrefslogtreecommitdiffstats
path: root/perl-install/printerdrake.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-03-17 18:28:37 +0000
committerFrancois Pons <fpons@mandriva.com>2000-03-17 18:28:37 +0000
commitc2291d42ccff39452769c2c5d1e62842765dcf7b (patch)
tree14ce67c307837e19500279e7d0133ac53933f329 /perl-install/printerdrake.pm
parent3622540f67228fabb5399876b5af89f37cf461be (diff)
downloaddrakx-backup-do-not-use-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar
drakx-backup-do-not-use-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar.gz
drakx-backup-do-not-use-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar.bz2
drakx-backup-do-not-use-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar.xz
drakx-backup-do-not-use-c2291d42ccff39452769c2c5d1e62842765dcf7b.zip
*** empty log message ***
Diffstat (limited to 'perl-install/printerdrake.pm')
-rw-r--r--perl-install/printerdrake.pm151
1 files changed, 50 insertions, 101 deletions
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index a6a2061f1..9bf53776d 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -13,53 +13,6 @@ use printer;
1;
-sub getinfo($) {
- my ($prefix) = @_;
- my $printer = {};
-
- printer::set_prefix($prefix);
- printer::read_configured_queue($printer);
-
- add2hash($printer, {
- want => 0,
- complete => 0,
- str_type => $printer::printer_type_default,
- QUEUE => "lp",
- SPOOLDIR => "/var/spool/lpd/lp",
- DBENTRY => "PostScript",
- PAPERSIZE => "letter",
- ASCII_TO_PS => undef,
- CRLF => undef,
- NUP => 1,
- RTLFTMAR => 18,
- TOPBOTMAR => 18,
- AUTOSENDEOF => 1,
-
- DEVICE => "/dev/lp0",
-
- REMOTEHOST => "",
- REMOTEQUEUE => "",
-
- NCPHOST => "", #-"printerservername",
- NCPQUEUE => "", #-"queuename",
- NCPUSER => "", #-"user",
- NCPPASSWD => "", #-"pass",
-
- SMBHOST => "", #-"hostname",
- SMBHOSTIP => "", #-"1.2.3.4",
- SMBSHARE => "", #-"printername",
- SMBUSER => "", #-"user",
- SMBPASSWD => "", #-"passowrd",
- SMBWORKGROUP => "", #-"AS3",
- });
- $printer;
-}
-
-sub copy_printer_params($$) {
- my ($from, $to) = @_;
- map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from; #- avoid cycles.
-}
-
sub setup_local($$$) {
my ($printer, $in, $install) = @_;
@@ -104,7 +57,7 @@ sub setup_remote($$$) {
_("To use a remote lpd print queue, you need to supply
the hostname of the printer server and the queue name
on that server which jobs should be placed in."), [
-_("Remote hostname:") => \$printer->{REMOTEHOST},
+_("Remote hostname") => \$printer->{REMOTEHOST},
_("Remote queue") => \$printer->{REMOTEQUEUE}, ],
);
}
@@ -119,12 +72,12 @@ SMB host name (Note! It may be different from its
TCP/IP hostname!) and possibly the IP address of the print server, as
well as the share name for the printer you wish to access and any
applicable user name, password, and workgroup information."), [
-_("SMB server host:") => \$printer->{SMBHOST},
-_("SMB server IP:") => \$printer->{SMBHOSTIP},
-_("Share name:") => \$printer->{SMBSHARE},
-_("User name:") => \$printer->{SMBUSER},
-_("Password:") => { val => \$printer->{SMBPASSWD}, hidden => 1 },
-_("Workgroup:") => \$printer->{SMBWORKGROUP} ],
+_("SMB server host") => \$printer->{SMBHOST},
+_("SMB server IP") => \$printer->{SMBHOSTIP},
+_("Share name") => \$printer->{SMBSHARE},
+_("User name") => \$printer->{SMBUSER},
+_("Password") => { val => \$printer->{SMBPASSWD}, hidden => 1 },
+_("Workgroup") => \$printer->{SMBWORKGROUP} ],
complete => sub {
unless (network::is_ip($printer->{SMBHOSTIP})) {
$in->ask_warn('', _("IP address should be in format 1.2.3.4"));
@@ -145,10 +98,10 @@ _("To print to a NetWare printer, you need to provide the
NetWare print server name (Note! it may be different from its
TCP/IP hostname!) as well as the print queue name for the printer you
wish to access and any applicable user name and password."), [
-_("Printer Server:") => \$printer->{NCPHOST},
-_("Print Queue Name:") => \$printer->{NCPQUEUE},
-_("User name:") => \$printer->{NCPUSER},
-_("Password:") => {val => \$printer->{NCPPASSWD}, hidden => 1} ],
+_("Printer Server") => \$printer->{NCPHOST},
+_("Print Queue Name") => \$printer->{NCPQUEUE},
+_("User name") => \$printer->{NCPUSER},
+_("Password") => {val => \$printer->{NCPPASSWD}, hidden => 1} ],
);
&$install('ncpfs');
1;
@@ -167,14 +120,14 @@ sub setup_gsdriver($$) {
do {
$printer->{DBENTRY} ||= $printer::thedb_gsdriver{$printer->{GSDRIVER}}{ENTRY};
- $printer->{DBENTRY} =
- $printer::descr_to_db{
+ eval { $printer->{DBENTRY} = $printer::descr_to_db{
$in->ask_from_list_(_("Configure Printer"),
_("What type of printer do you have?"),
[@printer::entry_db_description],
$printer::db_to_descr{$printer->{DBENTRY}},
)
};
+ }; $@ =~ /^ask_from_list cancel/ and return;
my %db_entry = %{$printer::thedb{$printer->{DBENTRY}}};
@@ -191,8 +144,8 @@ sub setup_gsdriver($$) {
$printer->{CRLF} = $db_entry{DESCR} =~ /HP/ unless defined($printer->{CRLF});
$printer->{BITSPERPIXEL} = @list_col ? $depth_to_col{$printer->{BITSPERPIXEL}} || $col[0] : "Default";
$printer->{NUP} = 1 unless member($printer->{NUP}, qw(1 2 4 8));
- $printer->{RTFLTMAP} = 18 unless $printer->{RTFLTMAP} =~ /^\d+$/;
- $printer->{TOPBOTMAP} = 18 unless $printer->{TOPBOTMAP} =~ /^\d+$/;
+ $printer->{RTLFTMAR} = 18 unless $printer->{RTLFTMAR} =~ /^\d+$/;
+ $printer->{TOPBOTMAR} = 18 unless $printer->{TOPBOTMAR} =~ /^\d+$/;
$printer->{EXTRA_GS_OPTIONS} =~ s/^\"(.*)\"/$1/;
$printer->{TEXTONLYOPTIONS} =~ s/^\"(.*)\"/$1/;
@@ -213,8 +166,8 @@ _("Fix stair-stepping text?") => { val => \$printer->{CRLF}, type => 'bool' },
) : (),
$db_entry{GSDRIVER} ne 'TEXT' ? (
_("Number of pages per output pages") => { val => \$printer->{NUP}, type => 'list', not_edit => !$::expert, list => [1,2,4,8] },
-_("Right/Left margins in points (1/72 of inch)") => \$printer->{RTFLTMAP},
-_("Top/Bottom margins in points (1/72 of inch)") => \$printer->{TOPBOTMAP},
+_("Right/Left margins in points (1/72 of inch)") => \$printer->{RTLFTMAR},
+_("Top/Bottom margins in points (1/72 of inch)") => \$printer->{TOPBOTMAR},
) : (),
$::expert && $db_entry{GSDRIVER} ne 'TEXT' && $db_entry{GSDRIVER} ne 'POSTSCRIPT' ? (
_("Extra GhostScript options") => \$printer->{EXTRA_GS_OPTIONS},
@@ -227,7 +180,7 @@ _("Extra Text options") => \$printer->{TEXTONLYOPTIONS},
$printer->{BITSPERPIXEL} = $col_to_depth{$printer->{BITSPERPIXEL}} || $printer->{BITSPERPIXEL}; #- translate back.
$printer->{complete} = 1;
- copy_printer_params($printer, $printer->{configured}{$printer->{QUEUE}} ||= {});
+ printer::copy_printer_params($printer, $printer->{configured}{$printer->{QUEUE}} ||= {});
printer::configure_queue($printer);
$printer->{complete} = 0;
@@ -245,8 +198,8 @@ _("Extra Text options") => \$printer->{TEXTONLYOPTIONS},
{
my $w = $in->wait_message('', _("Printing test page(s)..."));
- printer::restart_queue($printer->{QUEUE});
- @lpq_output = printer::print_pages($printer->{QUEUE}, @testpages);
+ printer::restart_queue(printer::default_queue($printer->{QUEUE}));
+ @lpq_output = printer::print_pages(printer::default_queue($printer->{QUEUE}), @testpages);
}
if (@lpq_output) {
@@ -266,12 +219,11 @@ Does it work properly?"), 1) ? 'done' : 'change';
#- Program entry point.
sub main($$$) {
my ($printer, $in, $install) = @_;
- my ($queue, $continue);
+ my ($queue, $continue) = ('', 1);
- printer::read_printer_db();
- do {
+ while ($continue) {
if ($::beginner || !(scalar keys %{$printer->{configured} || {}})) {
- $queue = $in->ask_yesorno(_("Printer"),
+ $queue = $printer->{configured}{lp} || $in->ask_yesorno(_("Printer"),
_("Would you like to configure a printer?"),
$printer->{want}) ? 'lp' : 'Done';
} else {
@@ -281,55 +233,47 @@ You can add some more or change the existing ones."),
[ (sort keys %{$printer->{configured} || {}}), __("Add"), __("Done") ],
);
if ($queue eq 'Add') {
- my $i = '';
- while ($i < 99) {
- last unless $printer->{configured}{"lp$i"};
- ++$i;
- }
- unless ($printer->{configured}{"lp$i"}) {
- $queue = "lp$i";
- $printer->{QUEUE} = $queue;
- $printer->{SPOOLDIR} = "$printer::spooldir/$printer->{QUEUE}";
- }
+ my %queues; @queues{map { split '\|', $_ } keys %{$printer->{configured}}} = ();
+ my $i = ''; while ($i < 100) { last unless exists $queues{"lp$i"}; ++$i; }
+ $queue = "lp$i";
}
}
$queue eq 'Done' and last;
- copy_printer_params($printer->{configured}{$queue}, $printer) if $printer->{configured}{$queue};
- $printer->{complete} = 0; #- ??? keep that
-
&$install('rhs-printfilters') unless $::testing;
+ printer::read_printer_db();
- do {
+ printer::copy_printer_params($printer->{configured}{$queue}, $printer) if $printer->{configured}{$queue};
+ $printer->{OLD_QUEUE} = $printer->{QUEUE} = $queue; #- keep in mind old name of queue (in case of changing)
+
+ while ($continue) {
+ $printer->{TYPE} = 'LOCAL' unless $printer::printer_type_inv{$printer->{TYPE}};
+ $printer->{str_type} = $printer::printer_type_inv{$printer->{TYPE}};
if ($::beginner) {
$printer->{str_type} =
$in->ask_from_list_(_("Select Printer Connection"),
_("How is the printer connected?"),
[ keys %printer::printer_type ],
- $printer::printer_type_inv{$printer->{TYPE}},
+ $printer->{str_type},
);
- $printer->{TYPE} = $printer::printer_type{$printer->{str_type}};
} else {
- $in->ask_from_entries_refH([_("Select Printer Connection"), _("Ok"), _("Remove queue")],
+ $in->ask_from_entries_refH([_("Select Printer Connection"), _("Ok"), $::beginner ? () : _("Remove queue")],
_("Every print queue (which print jobs are directed to) needs a
name (often lp) and a spool directory associated with it. What
name and directory should be used for this queue and how is the printer connected?"), [
_("Name of queue:") => { val => \$printer->{QUEUE} },
_("Spool directory:") => { val => \$printer->{SPOOLDIR} },
-_("Printer Connection") => { val => \$printer->{str_type}, list => [ keys %printer::printer_type ] },
+_("Printer Connection") => { val => \$printer->{str_type}, not_edit => 1, list => [ keys %printer::printer_type ] },
],
changed => sub {
- $printer->{SPOOLDIR} = "$printer::spooldir/$printer->{QUEUE}" unless $_[0];
- },
- complete => sub {
- $printer->{TYPE} = $printer::printer_type{$printer->{str_type}} or
- $in->ask_warn('', _("Unknown printer connection!")), return (1, 2);
- return 0;
+ $printer->{SPOOLDIR} = "$printer::spooldir/" .
+ printer::default_queue($printer->{QUEUE}) unless $_[0];
}
- ) or delete $printer->{configured}{$queue}, redo; #- global redo on steps
+ ) or delete $printer->{configured}{$queue}, $continue = 1, last;
}
+ $printer->{TYPE} = $printer::printer_type{$printer->{str_type}};
- $continue = '';
+ $continue = 0;
for ($printer->{TYPE}) {
/LOCAL/ and setup_local ($printer, $in, $install) and last;
/REMOTE/ and setup_remote($printer, $in, $install) and last;
@@ -337,10 +281,15 @@ _("Printer Connection") => { val => \$printer->{str_type}, list => [ keys %print
/NCP/ and setup_ncp ($printer, $in, $install) and last;
$continue = 1; last;
}
- } while ($continue);
+ }
#- configure ghostscript driver to be used.
- setup_gsdriver($printer, $in);
-
- } until ($::beginner || $queue eq 'Done');
+ if (!$continue && setup_gsdriver($printer, $in)) {
+ delete $printer->{OLD_QUEUE}
+ if $printer->{QUEUE} ne $printer->{OLD_QUEUE} && $printer->{configured}{$printer->{QUEUE}};
+ $continue = !$::beginner;
+ } else {
+ $continue = 1;
+ }
+ }
}