summaryrefslogtreecommitdiffstats
path: root/perl-install/printer.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2001-08-12 00:08:52 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2001-08-12 00:08:52 +0000
commit9c9f0c07a2c376f812473400b7d7520cc711e545 (patch)
treedfa58a6283718187fb33cc7fad46e4198f173d92 /perl-install/printer.pm
parentb2464cbda3d5d38b3f83e447b70066f69beb25c3 (diff)
downloaddrakx-9c9f0c07a2c376f812473400b7d7520cc711e545.tar
drakx-9c9f0c07a2c376f812473400b7d7520cc711e545.tar.gz
drakx-9c9f0c07a2c376f812473400b7d7520cc711e545.tar.bz2
drakx-9c9f0c07a2c376f812473400b7d7520cc711e545.tar.xz
drakx-9c9f0c07a2c376f812473400b7d7520cc711e545.zip
"Expert Mode" button, better "Remote CUPS server" dialog, bugfixes
Diffstat (limited to 'perl-install/printer.pm')
-rw-r--r--perl-install/printer.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 208fd55b6..a592dbcb8 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -430,6 +430,50 @@ sub read_cups_options ($) {
}
#------------------------------------------------------------------------------
+
+sub read_cups_printer_list {
+ # This function reads in a list of all printers which the local CUPS
+ # daemon currently knows, including remote ones.
+ local *F;
+ open F, ($::testing ? "$prefix" : "chroot $prefix/ ") .
+ "lpstat -v |" || return ();
+ my @printerlist = ();
+ my $line;
+ while ($line = <F>) {
+ if ($line =~ m/^\s*device\s+for\s+([^:\s]+):\s*(\S+)\s*$/) {
+ my $queuename = $1;
+ my $comment = "";
+ if ($2 =~ m!^ipp://([^/:]+)[:/]!) {
+ $comment = _("(on %s)", $1);
+ } else {
+ $comment = _("(on this machine)");
+ }
+ push (@printerlist, "$queuename $comment");
+ }
+ }
+ close F;
+ return @printerlist;
+}
+
+sub get_cups_default_printer {
+ local *F;
+ open F, ($::testing ? "$prefix" : "chroot $prefix/ ") .
+ "lpstat -d |" || return undef;
+ my $line;
+ while ($line = <F>) {
+ if ($line =~ /^\s*system\s*default\s*destination:\s*(\S*)$/) {
+ return $1;
+ }
+ }
+ return undef;
+}
+
+sub set_cups_default_printer {
+ my $default = $_[0];
+ run_program::rooted($prefix, "lpoptions",
+ "-d", $default) || return;
+}
+
sub read_cupsd_conf {
my @cupsd_conf;
local *F;