summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/cups.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/printer/cups.pm')
-rw-r--r--perl-install/printer/cups.pm23
1 files changed, 17 insertions, 6 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm
index ab9e28b21..eb443482e 100644
--- a/perl-install/printer/cups.pm
+++ b/perl-install/printer/cups.pm
@@ -27,15 +27,17 @@ sub lpstat_lpv() {
my $currentitem = -1;
for my $line (@lpstat) {
- chomp ($line);
- if (!($line =~ m!^\s*$!)) {
- if ($line =~ m!^printer\s+(\S+)\s+(\S.*)$!) {
+ chomp($line);
+ if ($line !~ m!^\s*$!) {
+ if ($line =~ m!^printer\s+(\S+)\s+.*\b(enabled|disabled)\b!) {
# Beginning of new printer's entry
my $name = $1;
+ my $state = $2;
push(@items, {});
$currentitem = $#items;
$itemshash->{$name} = $currentitem;
$items[$currentitem]{queuename} ||= $name;
+ $items[$currentitem]{state} ||= $state;
} elsif ($line =~ m!^\s+Description:\s+(\S.*)$!) {
# Description field
if ($currentitem != -1) {
@@ -51,7 +53,7 @@ sub lpstat_lpv() {
my $name = $1;
my $uri = $2;
if (defined($itemshash->{$name})) {
- if ($uri !~ /:/) {$uri = "file:" . $uri};
+ if ($uri !~ /:/) { $uri = "file:" . $uri }
$currentitem = $itemshash->{$name};
if (($currentitem <= $#items) &&
($items[$currentitem]{queuename} eq $name)) {
@@ -114,10 +116,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();
}
@@ -133,4 +135,13 @@ sub get_remote_queues {
} lpstat_v();
}
+sub queue_enabled {
+ my ($queue) = @_;
+ 0 != grep {
+ /\b$queue\b.*\benabled\b/i;
+ } run_program::rooted_get_stdout($::prefix, 'lpstat', '-p', $queue);
+}
+
+
+
1;