summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/default.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-11-12 12:05:40 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-11-12 12:05:40 +0000
commit046406ab6b13659f4be843d3d2d5639efaf425fe (patch)
tree2304d9911b495ea5262815f2b3cca305f53d83f4 /perl-install/printer/default.pm
parent57582cf77904240eee6c29874866b9d62e4a9951 (diff)
downloaddrakx-046406ab6b13659f4be843d3d2d5639efaf425fe.tar
drakx-046406ab6b13659f4be843d3d2d5639efaf425fe.tar.gz
drakx-046406ab6b13659f4be843d3d2d5639efaf425fe.tar.bz2
drakx-046406ab6b13659f4be843d3d2d5639efaf425fe.tar.xz
drakx-046406ab6b13659f4be843d3d2d5639efaf425fe.zip
printer related modules cleaning :
- create the printer/ hierarchy - split services related stuff into services.pm & printer::services, - move things that've nothing to do with printers into common.pm (alternatives, permissions, ...) - move eveything related to cups, gimp-print, detection, {star,open}office to the corresponding splited printer:: module - big consolidation of printer::office (it was obvious there were tons of duplication between staroffice and openoffice managment) - move other stuff into printer::main, printer::common, status : print.pm has been heavily splited (now one can begin to understand the little bits). printerdrake still needs to be splited/cleaned and eventually removed since printer/printerdrake modules separation is not understandable by other people till, in printer::gimp, $lprcommand is neither declared nor setted nowhere. idem in mdk9.0 ...
Diffstat (limited to 'perl-install/printer/default.pm')
-rw-r--r--perl-install/printer/default.pm51
1 files changed, 51 insertions, 0 deletions
diff --git a/perl-install/printer/default.pm b/perl-install/printer/default.pm
new file mode 100644
index 000000000..5c15645d2
--- /dev/null
+++ b/perl-install/printer/default.pm
@@ -0,0 +1,51 @@
+package printer::default;
+
+use strict;
+use run_program;
+use common;
+
+#-configuration directory of Foomatic
+my $FOOMATICCONFDIR = "/etc/foomatic";
+#-location of the file containing the default spooler's name
+my $FOOMATIC_DEFAULT_SPOOLER = "$FOOMATICCONFDIR/defaultspooler";
+
+sub set_printer {
+ my ($printer) = $_[0];
+ run_program::rooted($::prefix, "foomatic-configure",
+ "-D", "-q", "-s", $printer->{SPOOLER},
+ "-n", $printer->{DEFAULT}) or return 0;
+ return 1;
+}
+
+sub get_printer {
+ my $printer = $_[0];
+ local *F;
+ open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -Q -q -s $printer->{SPOOLER} |" or return undef;
+ my $line;
+ while ($line = <F>) {
+ if ($line =~ m!^\s*<defaultqueue>(.*)</defaultqueue>\s*$!) {
+ return $1;
+ }
+ }
+ return undef;
+}
+
+sub printer_type($) { "LOCAL" }
+
+sub get_spooler () {
+ if (-f "$::prefix$FOOMATIC_DEFAULT_SPOOLER") {
+ my $spool = cat_("$::prefix$FOOMATIC_DEFAULT_SPOOLER");
+ chomp $spool;
+ return $spool if $spool =~ /cups|lpd|lprng|pdq/;
+ }
+}
+
+sub set_spooler ($) {
+ my ($printer) = @_;
+ # Mark the default driver in a file
+ output_p("$::prefix$FOOMATIC_DEFAULT_SPOOLER", $printer->{SPOOLER});
+}
+
+
+1;