diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/printer/main.pm | 50 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 67 | ||||
-rwxr-xr-x | perl-install/standalone/printerdrake | 11 |
3 files changed, 123 insertions, 5 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 73537f25e..78085b39e 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -689,8 +689,6 @@ sub read_ppd_options ($) { return $COMBODATA->{args}; } -my %sysconfig = getVarsFromSh("$::prefix/etc/sysconfig/printing"); - sub set_cups_special_options { my ($queue) = @_; # Set some special CUPS options @@ -714,6 +712,8 @@ sub set_cups_special_options { return 1; } +my %sysconfig = getVarsFromSh("$::prefix/etc/sysconfig/printing"); + sub set_cups_autoconf { my ($autoconf) = @_; $sysconfig{CUPS_CONFIG} = $autoconf ? "automatic" : "manual"; @@ -734,6 +734,52 @@ sub set_usermode { sub get_usermode() { $sysconfig{USER_MODE} eq 'expert' ? 1 : 0 } +sub set_auto_admin { + my ($printer) = @_; + $sysconfig{ENABLE_QUEUES_ON_PRINTER_CONNECTED} = + $printer->{enablequeuesonnewprinter} ? "yes" : "no"; + $sysconfig{AUTO_SETUP_QUEUES_ON_PRINTER_CONNECTED} = + $printer->{autoqueuesetuponnewprinter} ? "yes" : "no"; + $sysconfig{ENABLE_QUEUES_ON_SPOOLER_START} = + $printer->{enablequeuesonspoolerstart} ? "yes" : "no"; + $sysconfig{AUTO_SETUP_QUEUES_ON_SPOOLER_START} = + $printer->{autoqueuesetuponspoolerstart} ? "yes" : "no"; + $sysconfig{AUTO_SETUP_QUEUES_ON_PRINTERDRAKE_START} = + $printer->{autoqueuesetuponstart} ? "yes" : "no"; + $sysconfig{AUTO_SETUP_QUEUES_MODE} = + $printer->{autoqueuesetupgui} ? "waitforgui" : "nogui"; + setVarsInSh("$::prefix/etc/sysconfig/printing", \%sysconfig); + return 1; +} + +sub get_auto_admin { + my ($printer) = @_; + $printer->{enablequeuesonnewprinter} = + (!defined($sysconfig{ENABLE_QUEUES_ON_PRINTER_CONNECTED}) || + ($sysconfig{ENABLE_QUEUES_ON_PRINTER_CONNECTED} =~ /yes/i) ? + 1 : 0); + $printer->{autoqueuesetuponnewprinter} = + (!defined($sysconfig{AUTO_SETUP_QUEUES_ON_PRINTER_CONNECTED}) || + ($sysconfig{AUTO_SETUP_QUEUES_ON_PRINTER_CONNECTED} =~ /yes/i) ? + 1 : 0); + $printer->{enablequeuesonspoolerstart} = + (!defined($sysconfig{ENABLE_QUEUES_ON_SPOOLER_START}) || + ($sysconfig{ENABLE_QUEUES_ON_SPOOLER_START} =~ /yes/i) ? + 1 : 0); + $printer->{autoqueuesetuponspoolerstart} = + (!defined($sysconfig{AUTO_SETUP_QUEUES_ON_SPOOLER_START}) || + ($sysconfig{AUTO_SETUP_QUEUES_ON_SPOOLER_START} =~ /yes/i) ? + 1 : 0); + $printer->{autoqueuesetuponstart} = + (!defined($sysconfig{AUTO_SETUP_QUEUES_ON_PRINTERDRAKE_START}) || + ($sysconfig{AUTO_SETUP_QUEUES_ON_PRINTERDRAKE_START} =~ /yes/i) ? + 1 : 0); + $printer->{autoqueuesetupgui} = + (!defined($sysconfig{AUTO_SETUP_QUEUES_MODE}) || + ($sysconfig{AUTO_SETUP_QUEUES_MODE} =~ /waitforgui/i) ? + 1 : 0); +} + sub set_jap_textmode { my $textmode = ($_[0] ? 'cjk' : ''); # Do not write mime.convs if the file does not exist, as then diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index ab1cc4510..f7f22598e 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -600,6 +600,66 @@ N("Examples for correct IPs:\n") . return $retvalue; } +sub config_auto_admin { + my ($printer, $in) = @_; + + local $::isWizard = 0; + local $::isEmbedded = 0; + + # Read current configuration + printer::main::get_auto_admin($printer); + + # Configuration dialog + my $waitforgui = + N("Allow pop-up windows, package installation possible"); + my $nogui = + N("No pop-up windows, package installation not possible"); + my $autoqueuesetupmode = + $printer->{autoqueuesetupgui} ? $waitforgui : $nogui; + if ($in->ask_from_ + ({ + title => N("Printer auto administration"), + messages => N("Here you can configure printer administration tasks which should be done automatically."), + }, + [ + { val => N("Do automatic configuration of new printers") }, + { text => N("when a USB printer is connected and turned on"), + type => 'bool', + val => \$printer->{autoqueuesetuponnewprinter} }, + { text => N("when the printing system is started"), + type => 'bool', + val => \$printer->{autoqueuesetuponspoolerstart} }, + { text => N("when Printerdrake is started"), + type => 'bool', + val => \$printer->{autoqueuesetuponstart} }, + { val => N("Mode for automatic printer setup:") }, + { val => \$autoqueuesetupmode, + list => [ $waitforgui, $nogui ], + not_edit => 1, sort => 0, + type => 'list' }, + { val => N("Re-enable disabled printers") }, + { text => N("when a USB printer is connected and turned on"), + type => 'bool', + val => \$printer->{enablequeuesonnewprinter} }, + { text => N("when the printing system is started"), + type => 'bool', + val => \$printer->{enablequeuesonspoolerstart} }, + ] + ) + ) { + # Auto queue setup mode + $printer->{autoqueuesetupgui} = + ($autoqueuesetupmode eq $waitforgui ? 1 : 0); + # Save new settings + printer::main::set_auto_admin($printer); + return 1; + } else { + # Reset original settings + printer::main::get_auto_admin($printer); + return 0; + } +} + sub choose_printer_type { my ($printer, $in, $upNetwork) = @_; my $havelocalnetworks = check_network($printer, $in, $upNetwork, 1) && @@ -4683,13 +4743,16 @@ sub init { # Save the user mode, so that the same one is used on the next start # of Printerdrake printer::main::set_usermode($printer->{expert}); - + + # Get the settings for printer auto administration + printer::main::get_auto_admin($printer); + # only experts should be asked for the spooler also for background # installation of print it should not be asked for the spooler, # as this feature is only supported for CUPS. $printer->{SPOOLER} ||= 'cups' if (!$printer->{expert} || $::noX || $::autoqueue) && !$::isInstall; - + # If we have chosen a spooler, install it and mark it as default # spooler. Spooler installation is ommitted on background queue # installation, because this only works when CUPS is already running diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake index 2c4cc8eb2..03b0dcac1 100755 --- a/perl-install/standalone/printerdrake +++ b/perl-install/standalone/printerdrake @@ -21,7 +21,8 @@ use strict; -# i18n: IMPORTANT: to get correct namespace (userdrake instead of libDrakX) +# i18n: IMPORTANT: to get correct namespace (printerdrake instead of +# libDrakX) BEGIN { unshift @::textdomains, 'drakconf' } use lib qw(/usr/lib/libDrakX); @@ -165,6 +166,7 @@ my ($menu, $factory) = create_factory_menu($::isEmbedded ? $::Plug : $us->{wnd}{ %printer::main::thedb = (); }, undef, '<CheckItem>' ], + [ N("/_Options") . N("/Configure _Auto Administration"), undef, \&ConfigAutoAdmin, undef, '<StockItem>', 'gtk-autoadmin' ], [ N("/_Help"), undef, undef, undef, '<Branch>' ], if_(-x "/usr/sbin/drakhelp_inst", [ N("/_Help") . N("/_Help"), undef, sub { HelpSystem() }, undef, '<StockItem>', 'gtk-help' ], @@ -419,6 +421,13 @@ sub ConfigCUPS() { activate_mainwindow(); } +sub ConfigAutoAdmin() { + deactivate_mainwindow(); + printer::printerdrake::config_auto_admin($printer, $in); + Refresh($stringsearch); + activate_mainwindow(); +} + sub deactivate_mainwindow() { $us->{wnd}{rwindow}->set_sensitive(0); gtkset_mousecursor_wait(); |