summaryrefslogtreecommitdiffstats
path: root/perl-install/printer.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2002-08-28 16:25:22 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2002-08-28 16:25:22 +0000
commitc49ae686d5b9770861fbdaa860c81022808c3881 (patch)
tree31f6fc316ea6aa0d4cfc2505d6337afb98ae8675 /perl-install/printer.pm
parent27fd3d851753ac9e25ae7c6ee4ac38c02d3bca97 (diff)
downloaddrakx-backup-do-not-use-c49ae686d5b9770861fbdaa860c81022808c3881.tar
drakx-backup-do-not-use-c49ae686d5b9770861fbdaa860c81022808c3881.tar.gz
drakx-backup-do-not-use-c49ae686d5b9770861fbdaa860c81022808c3881.tar.bz2
drakx-backup-do-not-use-c49ae686d5b9770861fbdaa860c81022808c3881.tar.xz
drakx-backup-do-not-use-c49ae686d5b9770861fbdaa860c81022808c3881.zip
Printerdrake remembers now whether it was in normal mode or in expert
mode last time.
Diffstat (limited to 'perl-install/printer.pm')
-rw-r--r--perl-install/printer.pm51
1 files changed, 49 insertions, 2 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index fc2e0bc6f..145dac96a 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -1150,7 +1150,7 @@ sub set_cups_autoconf {
# Remove all valid "CUPS_CONFIG" lines
(/^\s*CUPS_CONFIG/ and $_ = "") foreach @file_content;
- # Insert the new "Printcap" line
+ # Insert the new "CUPS_CONFIG" line
if ($autoconf) {
push @file_content, "CUPS_CONFIG=automatic\n";
} else {
@@ -1170,7 +1170,7 @@ sub set_cups_autoconf {
sub get_cups_autoconf {
local *F;
- open F, ("< $prefix/etc/sysconfig/printing") || return 1;
+ open F, "< $prefix/etc/sysconfig/printing" or return 1;
my $line;
while ($line = <F>) {
if ($line =~ m!^[^\#]*CUPS_CONFIG=manual!) {
@@ -1180,6 +1180,53 @@ sub get_cups_autoconf {
return 1;
}
+sub set_usermode {
+ my $usermode = $_[0];
+ $::expert = $usermode;
+
+ # Read config file
+ local *F;
+ my $file = "$prefix/etc/sysconfig/printing";
+ if (!(-f $file)) {
+ @file_content = ();
+ } else {
+ open F, "< $file" or die "Cannot open $file!";
+ @file_content = <F>;
+ close F;
+ }
+
+ # Remove all valid "USER_MODE" lines
+ (/^\s*USER_MODE/ and $_ = "") foreach @file_content;
+
+ # Insert the new "USER_MODE" line
+ if ($usermode) {
+ push @file_content, "USER_MODE=expert\n";
+ } else {
+ push @file_content, "USER_MODE=recommended\n";
+ }
+
+ # Write back modified file
+ open F, "> $file" or die "Cannot open $file!";
+ print F @file_content;
+ close F;
+
+ return 1;
+}
+
+sub get_usermode {
+ local *F;
+ open F, "< $prefix/etc/sysconfig/printing" or return 0;
+ my $line;
+ while ($line = <F>) {
+ if ($line =~ m!^[^\#]*USER_MODE=expert!) {
+ $::expert = 1;
+ return 1;
+ }
+ }
+ $::expert = 0;
+ return 0;
+}
+
sub set_default_printer {
my ($printer) = $_[0];
run_program::rooted($prefix, "foomatic-configure",