summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/printer/cups.pm4
-rw-r--r--perl-install/printer/data.pm2
-rw-r--r--perl-install/printer/default.pm8
-rw-r--r--perl-install/printer/main.pm108
-rw-r--r--perl-install/printer/printerdrake.pm194
-rwxr-xr-xperl-install/standalone/printerdrake41
6 files changed, 285 insertions, 72 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm
index ab9e28b21..79ca291b3 100644
--- a/perl-install/printer/cups.pm
+++ b/perl-install/printer/cups.pm
@@ -114,10 +114,10 @@ sub get_formatted_remote_queues {
map {
join('!', if_($printer->{expert}, N("CUPS")), N("Configured on other machines"), $_);
} map {
- my $comment = N("On CUPS server \"%s\"", $_->{ipp}) . ($_->{queuename} eq $printer->{DEFAULT} ? N(" (Default)") : "");
+ my $comment = N("On CUPS server \"%s\"", ($_->{ipp} ? $_->{ipp} : $printer->{remote_cups_server})) . ($_->{queuename} eq $printer->{DEFAULT} ? N(" (Default)") : "");
"$_->{queuename}: $comment";
} grep {
- $_->{ipp} && !$printer->{configured}{$_->{queuename}};
+ !$printer->{configured}{$_->{queuename}};
} lpstat_v();
}
diff --git a/perl-install/printer/data.pm b/perl-install/printer/data.pm
index 25cacbe26..47727b5ea 100644
--- a/perl-install/printer/data.pm
+++ b/perl-install/printer/data.pm
@@ -130,7 +130,7 @@ our %spoolers = ('pdq' => {
'print_command' => 'lpr-cups',
'print_gui' => 'xpp',
'long_name' => N("CUPS - Common Unix Printing System (remote server)"),
- 'short_name' => N("RemoteCUPS"),
+ 'short_name' => N("Remote CUPS"),
'local_queues' => 0,
'packages2add' => [ ['cups-common'],
['/usr/bin/lpr-cups'] ],
diff --git a/perl-install/printer/default.pm b/perl-install/printer/default.pm
index af997fd48..b6f45c889 100644
--- a/perl-install/printer/default.pm
+++ b/perl-install/printer/default.pm
@@ -11,17 +11,21 @@ my $FOOMATIC_DEFAULT_SPOOLER = "$FOOMATICCONFDIR/defaultspooler";
sub set_printer {
my ($printer) = $_[0];
+ my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
run_program::rooted($::prefix, "foomatic-configure",
- "-D", "-q", "-s", $printer->{SPOOLER},
+ "-D", "-q", "-s", $spooler,
"-n", $printer->{DEFAULT}) or return 0;
return 1;
}
sub get_printer {
my $printer = $_[0];
+ my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
local *F;
open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -Q -q -s $printer->{SPOOLER} |" or return undef;
+ "foomatic-configure -Q -q -s $spooler |" or return undef;
my $line;
while ($line = <F>) {
if ($line =~ m!^\s*<defaultqueue>(.*)</defaultqueue>\s*$!) {
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index 1e5e24452..349d98a50 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -55,7 +55,7 @@ sub spooler() {
# PDQ is not officially supported any more since version 9.1, so
# show it only in the spooler menu when it was manually installed.
- return map { $spoolers{$_}{long_name} } qw(cups),
+ return map { $spoolers{$_}{long_name} } qw(cups, rcups),
if_(files_exist(qw(/usr/bin/pdq)), 'pdq'),
if_(files_exist(qw(/usr/lib/filters/lpf /usr/sbin/lpd)), 'lprng');
}
@@ -67,14 +67,15 @@ sub printer_type($) {
/lpd/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($printer->{expert}, qw(POSTPIPE URI))};
/lprng/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($printer->{expert}, qw(POSTPIPE URI))};
/pdq/ and return @printer_type_inv{qw(LOCAL LPD SOCKET), if_($printer->{expert}, qw(URI))};
+ /rcups/ and return ();
}
}
sub SIGHUP_daemon {
my ($service) = @_;
if ($service eq "cupsd") { $service = "cups" };
- # PDQ has no daemon, exit.
- if ($service eq "pdq") { return 1 };
+ # PDQ and remote CUPS have no daemons, exit.
+ if (($service eq "pdq") || ($service eq "rcups")) { return 1 };
# CUPS needs auto-correction for its configuration
run_program::rooted($::prefix, "/usr/sbin/correctcupsconfig") if $service eq "cups";
# Name of the daemon
@@ -219,23 +220,26 @@ sub read_configured_queues($) {
$printer->{SPOOLER} ||= printer::default::get_spooler();
if (!$printer->{SPOOLER}) {
#- Find the first spooler where there are queues
- foreach my $spooler (qw(cups pdq lprng lpd)) {
+ foreach my $spooler (qw(rcups cups pdq lprng lpd)) {
#- Is the spooler's daemon running?
my $service = $spooler;
if ($service eq "lprng") {
$service = "lpd";
}
- if ($service ne "pdq") {
+ if (($service ne "pdq") && ($service ne "rcups")) {
next unless services::is_service_running($service);
# daemon is running, spooler found
$printer->{SPOOLER} = $spooler;
}
- #- poll queue info
- open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -P -q -s $spooler |") or
- die "Could not run foomatic-configure";
- eval join('', <$F>);
- close $F;
+ #- poll queue info
+ if ($service ne "rcups") {
+ open(my $F, ($::testing ?
+ $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -P -q -s $spooler |") or
+ die "Could not run foomatic-configure";
+ eval join('', <$F>);
+ close $F;
+ }
if ($service eq "pdq") {
#- Have we found queues? PDQ has no damon, so we consider
#- it in use when there are defined printer queues
@@ -243,6 +247,17 @@ sub read_configured_queues($) {
$printer->{SPOOLER} = $spooler;
last;
}
+ } elsif ($service eq "rcups") {
+ #- In daemon-less CUPS mode there are no local queues,
+ #- we can only recognize it by a server entry in
+ #- /etc/cups/client.conf
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
+ if ($daemonless_cups) {
+ $printer->{SPOOLER} = $spooler;
+ $printer->{remote_cups_server} = $remote_cups_server;
+ last;
+ }
} else {
#- For other spoolers we have already found a running
#- daemon when we have arrived here
@@ -250,12 +265,18 @@ sub read_configured_queues($) {
}
}
} else {
- #- Poll the queues of the current default spooler
- open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -P -q -s $printer->{SPOOLER} -r |") or
- die "Could not run foomatic-configure";
- eval join('', <$F>);
- close $F;
+ if ($printer->{SPOOLER} ne "rcups") {
+ #- Poll the queues of the current default spooler
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -P -q -s $printer->{SPOOLER} -r |") or
+ die "Could not run foomatic-configure";
+ eval join('', <$F>);
+ close $F;
+ } else {
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
+ $printer->{remote_cups_server} = $remote_cups_server;
+ }
}
$printer->{configured} = {};
my $i;
@@ -438,6 +459,9 @@ sub read_printer_db {
my ($printer, $spooler) = @_;
+ # No local queues available in daemon-less CUPS mode
+ return 1 if $spooler eq "rcups";
+
my $DBPATH; #- don't have to do close ... and don't modify globals at least
# Generate the Foomatic printer/driver overview, read it from the
# appropriate file when it is already generated
@@ -697,13 +721,10 @@ sub get_jap_textmode() {
sub read_cupsd_conf() {
cat_("$::prefix/etc/cups/cupsd.conf");
}
+
sub write_cupsd_conf {
my (@cupsd_conf) = @_;
-
output("$::prefix/etc/cups/cupsd.conf", @cupsd_conf);
-
- #- restart cups after updating configuration.
- printer::services::restart("cups");
}
sub read_location {
@@ -1362,6 +1383,32 @@ sub clean_cups_config {
}
#----------------------------------------------------------------------
+# Handling of /etc/cups/client.conf
+
+sub read_client_conf() {
+ my @client_conf = cat_("$::prefix/etc/cups/client.conf");
+ my @servers = handle_configs::read_directives(\@client_conf,
+ "ServerName");
+ return (@servers > 0,
+ $servers[0]); # If there is more than one entry in client.conf,
+ # the first one counts.
+}
+
+sub write_client_conf {
+ my ($daemonless_cups, $remote_cups_server) = @_;
+ my (@client_conf) = cat_("$::prefix/etc/cups/client.conf");
+ if ($daemonless_cups) {
+ handle_configs::set_directive(\@client_conf,
+ "ServerName $remote_cups_server");
+ } else {
+ handle_configs::comment_directive(\@client_conf, "ServerName");
+ }
+ output("$::prefix/etc/cups/client.conf", @client_conf);
+}
+
+
+
+#----------------------------------------------------------------------
sub read_printers_conf {
my ($printer) = @_;
my $current;
@@ -1912,34 +1959,36 @@ sub print_pages($@) {
my $queue = $printer->{QUEUE};
my $lpr = "/usr/bin/foomatic-printjob";
my $lpq = "$lpr -Q";
+ my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
# Print the pages
foreach (@pages) {
my $page = $_;
- # Only text and PostScript can be printed directly with all spoolers,
- # images must be treated seperately
+ # Only text and PostScript can be printed directly with all
+ # spoolers, images must be treated seperately
if ($page =~ /\.jpg$/) {
- if ($printer->{SPOOLER} ne "cups") {
+ if ($spooler ne "cups") {
# Use "convert" from ImageMagick for non-CUPS spoolers
system(($::testing ? $::prefix : "chroot $::prefix/ ") .
"/usr/bin/convert $page -page 427x654+100+65 PS:- | " .
($::testing ? $::prefix : "chroot $::prefix/ ") .
- "$lpr -s $printer->{SPOOLER} -P $queue");
+ "$lpr -s $spooler -P $queue");
} else {
# Use CUPS's internal image converter with CUPS, tell it
# to let the image occupy 90% of the page size (so nothing
# gets cut off by unprintable borders)
- run_program::rooted($::prefix, $lpr, "-s", $printer->{SPOOLER},
+ run_program::rooted($::prefix, $lpr, "-s", $spooler,
"-P", $queue, "-o", "scaling=90", $page);
}
} else {
- run_program::rooted($::prefix, $lpr, "-s", $printer->{SPOOLER},
+ run_program::rooted($::prefix, $lpr, "-s", $spooler,
"-P", $queue, $page);
}
}
sleep 5; #- allow lpr to send pages.
# Check whether the job is queued
- open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "$lpq -s $printer->{SPOOLER} -P $queue |");
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "$lpq -s $spooler -P $queue |");
my @lpq_output =
grep { !/^no entries/ && !(/^Rank\s+Owner/ .. /^\s*$/) } <$F>;
close $F;
@@ -1984,6 +2033,9 @@ sub print_optionlist {
sub get_copiable_queues {
my ($oldspooler, $newspooler) = @_;
+ # No local queues available in daemon-less CUPS mode
+ return () if ($oldspooler eq "rcups") or ($newspooler eq "rcups");
+
my @queuelist; #- here we will list all Foomatic-generated queues
# Get queue list with foomatic-configure
open(my $QUEUEOUTPUT, ($::testing ? $::prefix : "chroot $::prefix/ ") .
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index fdf562ddc..314dfe31b 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -42,6 +42,9 @@ sub config_cups {
@{$printer->{cupsconfig}{cupsd_conf}} =
printer::main::read_cupsd_conf();
printer::main::read_cups_config($printer);
+ # Read client.conf file
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
# Read state of japanese text printing mode
my $jap_textmode = printer::main::get_jap_textmode();
# Read state for auto-correction of cupsd.conf
@@ -64,9 +67,15 @@ sub config_cups {
},
[
{ text => N("The printers on this machine are available to other computers"), type => 'bool',
- val => \$printer->{cupsconfig}{localprintersshared} },
+ val => \$printer->{cupsconfig}{localprintersshared},
+ disabled => sub {
+ $daemonless_cups;
+ } },
{ text => N("Automatically find available printers on remote machines"), type => 'bool',
- val => \$printer->{cupsconfig}{remotebroadcastsaccepted} },
+ val => \$printer->{cupsconfig}{remotebroadcastsaccepted},
+ disabled => sub {
+ $daemonless_cups;
+ } },
{ val => N("Printer sharing on hosts/networks: ") .
($printer->{cupsconfig}{customsharingsetup} ?
N("Custom configuration") :
@@ -81,6 +90,7 @@ sub config_cups {
1;
},
disabled => sub {
+ $daemonless_cups ||
(!$printer->{cupsconfig}{localprintersshared} &&
!$printer->{cupsconfig}{remotebroadcastsaccepted});
} },
@@ -95,11 +105,17 @@ sub config_cups {
clicked_may_quit => sub {
$buttonclicked = "browsepoll";
1;
+ },
+ disabled => sub {
+ $daemonless_cups;
} },
{ text => N("Japanese text printing mode"),
help => N("Turning on this allows to print plain text files in Japanese language. Only use this function if you really want to print text in Japanese, if it is activated you cannot print accentuated characters in latin fonts any more and you will not be able to adjust the margins, the character size, etc. This setting only affects printers defined on this machine. If you want to print Japanese text on a printer set up on a remote machine, you have to activate this function on that remote machine."),
type => 'bool',
- val => \$jap_textmode },
+ val => \$jap_textmode,
+ disabled => sub {
+ $daemonless_cups;
+ } },
if_($printer->{expert},
{ text => N("Automatic correction of CUPS configuration"),
type => 'bool',
@@ -112,7 +128,20 @@ sub config_cups {
- when printer information is broadcasted, it does not contain \"localhost\" as the server name.
If some of these measures lead to problems for you, turn this option off, but then you have to take care of these points."),
- val => \$printer->{cupsconfig}{autocorrection} }),
+ val => \$printer->{cupsconfig}{autocorrection},
+ disabled => sub {
+ $daemonless_cups;
+ } }),
+ { val => N("Remote CUPS server and no local CUPS daemon: ") .
+ ($daemonless_cups ?
+ N("On; Server:") . $remote_cups_server :
+ N("Off")),
+ help => N("In this mode the local CUPS daemon will be stopped and all printing requests go directly to the server specified below. Note that it is not possible to define local print queues then and if the specified server is down it cannot be printed at all from this machine."),
+ type => 'button',
+ clicked_may_quit => sub {
+ $buttonclicked = "daemonlesscups";
+ 1;
+ } },
]
)
) {
@@ -455,6 +484,53 @@ N("Examples for correct IPs:\n") .
printer::main::makebrowsepolllist($printer);
}
}
+ } elsif ($buttonclicked eq "daemonlesscups") {
+ my ($modechoice, $rserver);
+ if ($daemonless_cups) {
+ $modechoice = N("On, Name or IP of remote server:");
+ $rserver = $remote_cups_server;
+ } else {
+ $modechoice = N("Off");
+ }
+ # Show the dialog
+ #my $address;
+ #my $oldaddress =
+ # ($buttonclicked eq "edit" ?
+ # $sharehosts->{invhash}{$choice} : "");
+ if ($in->ask_from_
+ ({ title => N("Remote CUPS server and no local CUPS daemon"),
+ messages => N("In this mode the local CUPS daemon will be stopped and all printing requests go directly to the server specified below. Note that it is not possible to define local print queues then and if the specified server is down it cannot be printed at all from this machine."),
+ callbacks => {
+ complete => sub {
+ if ($modechoice eq
+ N("On, Name or IP of remote server:") &&
+ $rserver =~ /^\s*$/) {
+
+ $in->ask_warn(N("Error"), N("CUPS server name or IP address missing."));
+ return 1, 1;
+ }
+ return 0;
+ },
+ },
+ },
+ # Show the widgets
+ [ { val => \$modechoice, format => \&translate,
+ type => 'list',
+ sort => 0,
+ list => [ N("Off"),
+ N("On, Name or IP of remote server:") ]},
+ { val => \$rserver,
+ disabled => sub {
+ $modechoice ne
+ N("On, Name or IP of remote server:");
+ } },
+ ],
+ )) {
+ # OK was clicked, update the data
+ $daemonless_cups =
+ ($modechoice eq N("On, Name or IP of remote server:"));
+ $remote_cups_server = $rserver;
+ }
} else {
# We have clicked "OK"
$retvalue = 1;
@@ -467,6 +543,39 @@ N("Examples for correct IPs:\n") .
}
# Write state of japanese text printing mode
printer::main::set_jap_textmode($jap_textmode);
+ # Switch state of daemon-less CUPS mode and write
+ # client.conf
+ if (($daemonless_cups && $printer->{SPOOLER} ne "rcups") ||
+ (!$daemonless_cups && $printer->{SPOOLER} eq "rcups")) {
+ my $oldspooler = $printer->{SPOOLER};
+ $printer->{SPOOLER} = ($daemonless_cups ?
+ "rcups" : "cups");
+ if (install_spooler($printer, $in, $upNetwork, 1)) {
+ printer::default::set_spooler($printer);
+ printer::main::write_client_conf
+ ($daemonless_cups, $remote_cups_server);
+ $printer->{remote_cups_server} =
+ $remote_cups_server;
+ if ($printer->{SPOOLER} ne "rcups") {
+ # Get the queues of this spooler
+ my $_w = $in->wait_message
+ (N("Printerdrake"),
+ N("Reading printer data..."));
+ printer::main::read_configured_queues($printer);
+ # Re-read the printer database next time
+ %printer::main::thedb = ();
+ assure_default_printer_is_set($printer, $in);
+ }
+ } else {
+ $printer->{SPOOLER} = $oldspooler;
+ }
+ } elsif ($daemonless_cups) {
+ printer::main::write_client_conf($daemonless_cups,
+ $remote_cups_server);
+ $printer->{remote_cups_server} = $remote_cups_server;
+ } else {
+ undef $printer->{remote_cups_server};
+ }
# Write cupsd.conf
printer::main::write_cups_config($printer);
my $w =
@@ -474,6 +583,8 @@ N("Examples for correct IPs:\n") .
N("Restarting CUPS..."));
printer::main::write_cupsd_conf(
@{$printer->{cupsconfig}{cupsd_conf}});
+ #- restart cups after updating configuration.
+ printer::main::SIGHUP_daemon($printer->{SPOOLER});
undef $w;
}
} else {
@@ -3254,6 +3365,7 @@ It may take some time before the printer starts.\n");
sub printer_help {
my ($printer, $in) = @_;
my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
my $queue = $printer->{QUEUE};
my $default = $printer->{DEFAULT};
my $raw = 0;
@@ -3688,7 +3800,7 @@ Do you really want to configure printing on this machine?",
sub start_spooler_on_boot {
# Checks whether the spooler will be started at boot time and if not,
# ask the user whether he wants to start the spooler at boot time.
- my ($printer, $in, $service) = @_;
+ my ($printer, $in, $service, $silentspooleronboot) = @_;
# PDQ has no daemon, so nothing needs to be started :
return unless $service;
@@ -3698,7 +3810,8 @@ sub start_spooler_on_boot {
# $in->set_help('startSpoolerOnBoot') if $::isInstall;
if (!services::starts_on_boot($service)) {
- if ($in->ask_yesorno(N("Starting the printing system at boot time"),
+ if ($silentspooleronboot ||
+ $in->ask_yesorno(N("Starting the printing system at boot time"),
N("The printing system (%s) will not be started automatically when the machine is booted.
It is possible that the automatic starting was turned off by changing to a higher security level, because the printing system is a potential point for attacks.
@@ -3713,14 +3826,14 @@ Do you want to have the automatic starting of the printing system turned on agai
sub install_spooler {
# installs the default spooler and start its daemon
- my ($printer, $in, $upNetwork) = @_;
+ my ($printer, $in, $upNetwork, $silentspooleronboot) = @_;
return 1 if $::testing;
my $spooler = $printer->{SPOOLER};
# If the user refuses to install the spooler in high or paranoid
# security level, exit.
return 0 unless security_check($printer, $in, $spooler);
# should not happen
- return 1 if $spooler !~ /^(rcups|cups|lpd|lprng|pqd)$/;
+ return 0 if $spooler !~ /^(rcups|cups|lpd|lprng|pqd)$/;
my $w = $in->wait_message(N("Printerdrake"), N("Checking installed software..."));
# "lpr" conflicts with "LPRng", remove either "LPRng" or remove "lpr"
@@ -3745,8 +3858,6 @@ sub install_spooler {
push (@{$packages->[1]}, @{$commonpackages->[1]});
push (@{$packages->[1]}, @{$localqueuepackages->[1]}) if
$spoolers{$spooler}{local_queues};
- #use Data::Dumper;
- #print Dumper($packages);
if (@{$packages->[0]} && !files_exist(@{$packages->[1]})) {
undef $w;
$w = $in->wait_message(N("Printerdrake"), N("Installing %s..."), $spoolers{$spooler}{short_name});
@@ -3776,11 +3887,17 @@ sub install_spooler {
# Avoid unnecessary restarting of CUPS, this blocks the
# startup of printerdrake for several seconds.
printer::services::start_not_running_service("cups");
+ } elsif ($spooler eq "rcups") {
+ # Stop CUPS daemon, we want to run daemon-less
+ services::stop("cups") if services::is_service_running("cups");
+ # Do not start CUPS daemon during boot
+ services::do_not_start_service_on_boot("cups");
} elsif ($spoolers{$spooler}{service}) {
printer::services::restart($spoolers{$spooler}{service});
}
- # Set the choosen spooler tools as defaults for "lpr", "lpq", "lprm", ...
+ # Set the choosen spooler tools as defaults for "lpr", "lpq",
+ # "lprm", ...
foreach (@{$spoolers{$spooler}{alternatives}}) {
set_alternative($_->[0], $_->[1]);
}
@@ -3789,11 +3906,12 @@ sub install_spooler {
printer::main::pdq_panic_button($spooler eq 'pdq' ? "add" : "remove");
# Should it be started at boot time?
- start_spooler_on_boot($printer, $in, $spoolers{$spooler}{boot_spooler});
+ start_spooler_on_boot($printer, $in, $spoolers{$spooler}{boot_spooler},
+ $silentspooleronboot);
# Give a SIGHUP to the devfsd daemon to correct the permissions
# for the /dev/... files according to the spooler
- printer::main::SIGHUP_daemon("devfs");
+ #printer::main::SIGHUP_daemon("devfs");
1;
}
@@ -3995,7 +4113,8 @@ sub init {
# Non-interactive setup of newly detected printers (This is done
# only when not in expert mode, so we always have a spooler defined
# here)
- configure_new_printers($printer, $in, $upNetwork);
+ configure_new_printers($printer, $in, $upNetwork)
+ if $printer->{SPOOLER} ne "rcups";
# Make sure that default printer is registered
if ($nodefault && $printer->{DEFAULT}) {
@@ -4042,7 +4161,8 @@ sub mainwindow_interactive {
if (defined($printer->{configured}{$printer->{DEFAULT}})) {
$cursorpos =
$printer->{configured}{$printer->{DEFAULT}}{queuedata}{menuentry} . N(" (Default)");
- } elsif ($printer->{SPOOLER} eq "cups") {
+ } elsif (($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups")){
$cursorpos = find { /!$printer->{DEFAULT}:[^!]*$/ } printer::cups::get_formatted_remote_queues($printer);
}
}
@@ -4053,7 +4173,8 @@ sub mainwindow_interactive {
N(" (Default)") : "") }
keys(%{$printer->{configured}
|| {}})),
- ($printer->{SPOOLER} eq "cups" ?
+ (($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups") ?
sort(printer::cups::get_formatted_remote_queues($printer)) :
()));
my $noprinters = $#printerlist < 0;
@@ -4073,27 +4194,30 @@ sub mainwindow_interactive {
sort => 0, separator => "!", tree_expanded => 1,
quit_if_double_click => 1, allow_empty_list => 1,
list => \@printerlist }),
- { clicked_may_quit =>
- sub {
- # Save the cursor position
- $cursorpos = $menuchoice;
- $menuchoice = '@addprinter';
- 1;
- },
- val => N("Add a new printer") },
- ($printer->{SPOOLER} eq "cups" &&
+ ($printer->{SPOOLER} ne "rcups" ?
+ { clicked_may_quit =>
+ sub {
+ # Save the cursor position
+ $cursorpos = $menuchoice;
+ $menuchoice = '@addprinter';
+ 1;
+ },
+ val => N("Add a new printer") } : ()),
+ ((($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups")) &&
$havelocalnetworks ?
{ clicked_may_quit =>
- sub {
- # Save the cursor position
- $cursorpos = $menuchoice;
- $menuchoice = '@refresh';
- 1;
- },
- val => ($noprinters ?
- N("Display all available remote CUPS printers") :
- N("Refresh printer list (to display all available remote CUPS printers)")) } : ()),
- ($printer->{SPOOLER} eq "cups" &&
+ sub {
+ # Save the cursor position
+ $cursorpos = $menuchoice;
+ $menuchoice = '@refresh';
+ 1;
+ },
+ val => ($noprinters ?
+ N("Display all available remote CUPS printers") :
+ N("Refresh printer list (to display all available remote CUPS printers)")) } : ()),
+ ((($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups")) &&
$havelocalnetworks_or_expert ?
{ clicked_may_quit =>
sub {
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index f16cdafe1..a6f0abff8 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -95,6 +95,8 @@ $printer->{expert} = printer::main::get_usermode();
$commandline =~ /-expert/ and $printer->{expert} = 1;
$commandline =~ /-cups/ and
$printer->{SPOOLER} = 'cups' and printer::main::read_configured_queues($printer);
+$commandline =~ /-rcups/ and
+ $printer->{SPOOLER} = 'rcups' and printer::main::read_configured_queues($printer);
$commandline =~ /-lpr/ and
$printer->{SPOOLER} = 'lpd' and printer::main::read_configured_queues($printer);
$commandline =~ /-lpd/ and
@@ -139,6 +141,7 @@ $localtree = CreateTree($ltree_model);
$remotetree = CreateTree($rtree_model);
# slightly verbatimed from control-center
my %options = (
+ 'add' => [ N("/_Actions"), N("/_Add Printer") ],
'default' => [ N("/_Actions"), N("/Set as _Default") ],
'edit' => [ N("/_Actions"), N("/_Edit") ],
'delete' => [ N("/_Actions"), N("/_Delete") ],
@@ -175,7 +178,7 @@ my ($menu, $factory) = create_factory_menu($::isEmbedded ? $::Plug : $us->{wnd}{
);
%buttorcheck = map {
$_ => $factory->get_widget("<main>" . join '', map { s/_//; $_ } @{$options{$_}})
-}('default', 'edit', 'delete', 'expert');
+}('add', 'default', 'edit', 'delete', 'expert');
if (defined $buttorcheck{expert}) {
$buttorcheck{expert}->set_active($printer->{expert});
@@ -242,6 +245,9 @@ my @toolbwg = map {
);
my ($_tbadd, $tbdefault, $tbedit, $tbdel, $_tbref, $_tbconfig) = @toolbwg;
GrayDelEdit();
+foreach ($_tbadd, $buttorcheck{add}) { defined $_ and $_->set_sensitive($printer->{SPOOLER} ne "rcups")};
+$localtree->parent->parent->set_sensitive($printer->{SPOOLER} ne "rcups");
+$nb->set_current_page(1) if $printer->{SPOOLER} eq "rcups";
$fbut->signal_connect('clicked', sub { $stringsearch = $filter->get_text; Refresh($stringsearch) });
Refresh($stringsearch);
@@ -282,6 +288,7 @@ sub RefreshLocalPrintersFull {
my @printers;
defined $printer and @printers = keys %{$printer->{configured}};
$ltree_model->clear;
+ return if $printer->{SPOOLER} eq "rcups";
my @LocalReal;
LOOP: foreach my $p (@printers) {
# Apply string search to all fields, not only the printer name
@@ -317,7 +324,8 @@ sub RefreshRemotePrintersFull {
next LOOP if defined($printer->{configured}{$p->{queuename}});
# Apply string search to all fields, not only the printer name
my $queue = $p->{queuename};
- my $server = $p->{ipp};
+ my $server = ($p->{ipp} ?
+ $p->{ipp} : $printer->{remote_cups_server});
my $description = $p->{description};
my $location = $p->{location};
my $searchstr = "$queue|$server|$description|$location";
@@ -327,7 +335,8 @@ sub RefreshRemotePrintersFull {
foreach my $p (sort { lc($a->{queuename}) cmp lc($b->{queuename}) }
@RemoteReal) {
my $queue = $p->{queuename};
- my $server = $p->{ipp};
+ my $server = ($p->{ipp} ?
+ $p->{ipp} : $printer->{remote_cups_server});
my $description = $p->{description};
my $location = $p->{location};
my $default = ($queue eq $printer->{DEFAULT} ? "X" : "");
@@ -393,6 +402,9 @@ sub Delete() {
sub ConfigCUPS() {
deactivate_mainwindow();
printer::printerdrake::config_cups($printer, $in);
+ foreach ($_tbadd, $buttorcheck{add}) { defined $_ and $_->set_sensitive($printer->{SPOOLER} ne "rcups")};
+ $localtree->parent->parent->set_sensitive($printer->{SPOOLER} ne "rcups");
+ $nb->set_current_page(1) if $printer->{SPOOLER} eq "rcups";
Refresh($stringsearch);
activate_mainwindow();
}
@@ -481,7 +493,23 @@ sub CreateTree {
$tree->get_selection->set_mode('browse');
$tree->set_headers_visible(1);
$tree->set_rules_hint(1);
- $tree->get_selection->signal_connect('changed' => sub { foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) } });
+ $tree->get_selection->signal_connect('changed' => sub {
+ my (undef, $event) = @_;
+ my (undef, $iter) = $tree->get_selection->get_selected;
+ return unless $iter;
+ foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) }
+ my $queue = $tree_model->get($iter, 1);
+ if (!defined($printer->{configured}{$queue})) {
+ foreach ($tbdel, $buttorcheck{delete}) {
+ $_->set_sensitive(0);
+ }
+ }
+ if ($queue eq $printer->{DEFAULT}) {
+ foreach ($tbdefault, $buttorcheck{default}) {
+ $_->set_sensitive(0);
+ }
+ }
+ });
$tree->signal_connect(button_press_event => sub {
my (undef, $event) = @_;
my (undef, $iter) = $tree->get_selection->get_selected;
@@ -493,6 +521,11 @@ sub CreateTree {
$_->set_sensitive(0);
}
}
+ if ($queue eq $printer->{DEFAULT}) {
+ foreach ($tbdefault, $buttorcheck{default}) {
+ $_->set_sensitive(0);
+ }
+ }
Edit() if $event->type eq '2button-press';
});
$tree->signal_connect(key_press_event => sub {