summaryrefslogtreecommitdiffstats
path: root/perl-install/printer.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2001-08-13 23:10:37 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2001-08-13 23:10:37 +0000
commitffd31ad9109bc706fff71c5ecf859de1b86f9afe (patch)
tree524e1662d225b76184b0eed4c027431215b22fad /perl-install/printer.pm
parentba052d9ebafdce7bb673cea38b202a8a8056fab9 (diff)
downloaddrakx-backup-do-not-use-ffd31ad9109bc706fff71c5ecf859de1b86f9afe.tar
drakx-backup-do-not-use-ffd31ad9109bc706fff71c5ecf859de1b86f9afe.tar.gz
drakx-backup-do-not-use-ffd31ad9109bc706fff71c5ecf859de1b86f9afe.tar.bz2
drakx-backup-do-not-use-ffd31ad9109bc706fff71c5ecf859de1b86f9afe.tar.xz
drakx-backup-do-not-use-ffd31ad9109bc706fff71c5ecf859de1b86f9afe.zip
Automatic transfer of queues when changing the spooler.
Diffstat (limited to 'perl-install/printer.pm')
-rw-r--r--perl-install/printer.pm90
1 files changed, 90 insertions, 0 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 40ebc84a4..0781095d8 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -28,6 +28,14 @@ my $FOOMATIC_DEFAULT_SPOOLER = "$FOOMATICCONFDIR/defaultspooler";
);
%spooler_inv = reverse %spooler;
+%shortspooler = (
+ _("CUPS") => "cups",
+ _("LPRng") => "lprng",
+ _("LPD") => "lpd",
+ _("PDQ") => "pdq"
+);
+%shortspooler_inv = reverse %shortspooler;
+
%printer_type = (
_("Local printer") => "LOCAL",
_("Remote printer") => "REMOTE",
@@ -776,6 +784,88 @@ sub print_pages($@) {
@lpq_output;
}
+# ---------------------------------------------------------------
+#
+# Spooler config stuff
+#
+# ---------------------------------------------------------------
+
+sub get_copiable_queues {
+ my ($oldspooler, $newspooler) = @_;
+ local $_; #- use of while (<...
+
+ local *QUEUEOUTPUT; #- don't have to do close ... and don't modify globals
+ #- at least
+ my @queuelist; #- here we will list all Foomatic-generated queues
+ # Get queue list with foomatic-configure
+ open QUEUEOUTPUT, ($::testing ? "$prefix" : "chroot $prefix/ ") .
+ "foomatic-configure -Q -s $oldspooler |" ||
+ die "Could not run foomatic-configure";
+
+ my $entry = {};
+ my $inentry = 0;
+ while (<QUEUEOUTPUT>) {
+ chomp;
+ if ($inentry) {
+ # We are inside a queue entry
+ if (m!^\s*</queue>\s*$!) {
+ # entry completed
+ $inentry = 0;
+ if (($entry->{foomatic}) &&
+ ($entry->{spooler} eq $oldspooler)) {
+ # Is the connection type supported by the new
+ # spooler?
+ if ((($newspooler eq "cups") &&
+ (($entry->{connect} =~ /^file:/) ||
+ ($entry->{connect} =~ /^lpd:/) ||
+ ($entry->{connect} =~ /^socket:/) ||
+ ($entry->{connect} =~ /^smb:/) ||
+ ($entry->{connect} =~ /^ipp:/))) ||
+ ((($newspooler eq "lpd") ||
+ ($newspooler eq "lprng")) &&
+ (($entry->{connect} =~ /^file:/) ||
+ ($entry->{connect} =~ /^lpd:/) ||
+ ($entry->{connect} =~ /^socket:/) ||
+ ($entry->{connect} =~ /^smb:/) ||
+ ($entry->{connect} =~ /^ncp:/) ||
+ ($entry->{connect} =~ /^postpipe:/))) ||
+ (($newspooler eq "pdq") &&
+ (($entry->{connect} =~ /^file:/) ||
+ ($entry->{connect} =~ /^lpd:/) ||
+ ($entry->{connect} =~ /^socket:/)))) {
+ push(@queuelist, $entry->{name});
+ }
+ }
+ $entry = {};
+ } elsif (m!^\s*<name>(.+)</name>\s*$!) {
+ # queue name
+ $entry->{name} = $1;
+ } elsif (m!^\s*<connect>(.+)</connect>\s*$!) {
+ # connection type (URI)
+ $entry->{connect} = $1;
+ }
+ } else {
+ if (m!^\s*<queue\s+foomatic\s*=\s*\"?(\d+)\"?\s*spooler\s*=\s*\"?(\w+)\"?\s*>\s*$!) {
+ # new entry
+ $inentry = 1;
+ $entry->{foomatic} = $1;
+ $entry->{spooler} = $2;
+ }
+ }
+ }
+ close QUEUEOUTPUT;
+
+ return @queuelist;
+}
+
+sub copy_foomatic_queue {
+ my ($printer, $oldqueue, $oldspooler, $newqueue) = @_;
+ run_program::rooted($prefix, "foomatic-configure",
+ "-s", $printer->{SPOOLER},
+ "-n", $newqueue,
+ "-C", $oldspooler, $oldqueue);
+}
+
#-######################################################################################
#- Wonderful perl :(