summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2002-02-28 03:39:21 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2002-02-28 03:39:21 +0000
commit9d1ca8b6a5971e7b137428ebbe943ac616ca529b (patch)
treea6f6a842447f3cb0e1c58c66f451ecc69cf567dc /perl-install
parent09239fa296cc96d58667e6b5f0c37618ce930369 (diff)
downloaddrakx-9d1ca8b6a5971e7b137428ebbe943ac616ca529b.tar
drakx-9d1ca8b6a5971e7b137428ebbe943ac616ca529b.tar.gz
drakx-9d1ca8b6a5971e7b137428ebbe943ac616ca529b.tar.bz2
drakx-9d1ca8b6a5971e7b137428ebbe943ac616ca529b.tar.xz
drakx-9d1ca8b6a5971e7b137428ebbe943ac616ca529b.zip
- Fixes/Improvements on Star Office/Open Office support:
o When one switches the spooler, the entries of the printers under the old spooler are removed from Star Office/Open Office o Printers on remote CUPS servers (which are known through broadcasting) can be added to Star Office/Open Office
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer.pm168
-rw-r--r--perl-install/printerdrake.pm31
2 files changed, 179 insertions, 20 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 3ab281cc4..445e7aea8 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -1610,31 +1610,43 @@ sub configureapplications {
configureopenoffice($printer);
}
+sub addcupsremotetoapplications {
+ my ($printer, $queue) = @_;
+ return (addcupsremotetostaroffice($printer, $queue) &&
+ addcupsremotetoopenoffice($printer, $queue));
+}
+
sub removeprinterfromapplications {
my ($printer, $queue) = @_;
- removeprinterfromstaroffice($printer, $queue);
- removeprinterfromopenoffice($printer, $queue);
+ return (removeprinterfromstaroffice($printer, $queue) &&
+ removeprinterfromopenoffice($printer, $queue));
+}
+
+sub removelocalprintersfromapplications {
+ my ($printer) = @_;
+ removelocalprintersfromstaroffice($printer);
+ removelocalprintersfromopenoffice($printer);
}
sub configurestaroffice {
my ($printer) = @_;
# Do we have Star Office installed?
my $configfilename = findsofficeconfigfile();
- return 0 if !$configfilename;
+ return 1 if !$configfilename;
$configfilename =~ m!^(.*)/share/xp3/Xpdefaults$!;
my $configprefix = $1;
# Load Star Office printer config file
my $configfilecontent = readsofficeconfigfile($configfilename);
# Update remote CUPS queues
if (0 && ($printer->{SPOOLER} eq "cups") &&
- (-x "$prefix/usr/bin/wget")) {
+ (-x "$prefix/usr/bin/curl")) {
my @printerlist = getcupsremotequeues();
for my $listentry (@printerlist) {
next if !($listentry =~ /^([^\|]+)\|([^\|]+)$/);
my $queue = $1;
my $server = $2;
eval(run_program::rooted
- ($prefix, "wget", "-O", "/etc/foomatic/$queue.ppd",
+ ($prefix, "curl", "-o", "/etc/foomatic/$queue.ppd",
"http://$server:631/printers/$queue.ppd"));
if (-r "$prefix/etc/foomatic/$queue.ppd") {
$configfilecontent =
@@ -1670,28 +1682,28 @@ sub configurestaroffice {
$configfilecontent);
}
# Write back Star Office configuration file
- writesofficeconfigfile($configfilename, $configfilecontent);
+ return writesofficeconfigfile($configfilename, $configfilecontent);
}
sub configureopenoffice {
my ($printer) = @_;
# Do we have Open Office installed?
my $configfilename = findopenofficeconfigfile();
- return 0 if !$configfilename;
+ return 1 if !$configfilename;
$configfilename =~ m!^(.*)/share/psprint/psprint.conf$!;
my $configprefix = $1;
# Load Open Office printer config file
my $configfilecontent = readsofficeconfigfile($configfilename);
# Update remote CUPS queues
if (0 && ($printer->{SPOOLER} eq "cups") &&
- (-x "$prefix/usr/bin/wget")) {
+ (-x "$prefix/usr/bin/curl")) {
my @printerlist = getcupsremotequeues();
for my $listentry (@printerlist) {
next if !($listentry =~ /^([^\|]+)\|([^\|]+)$/);
my $queue = $1;
my $server = $2;
eval(run_program::rooted
- ($prefix, "wget", "-O", "/etc/foomatic/$queue.ppd",
+ ($prefix, "curl", "-o", "/etc/foomatic/$queue.ppd",
"http://$server:631/printers/$queue.ppd"));
if (-r "$prefix/etc/foomatic/$queue.ppd") {
$configfilecontent =
@@ -1727,14 +1739,97 @@ sub configureopenoffice {
$configfilecontent);
}
# Write back Open Office configuration file
- writesofficeconfigfile($configfilename, $configfilecontent);
+ return writesofficeconfigfile($configfilename, $configfilecontent);
+}
+
+sub addcupsremotetostaroffice {
+ my ($printer, $queue) = @_;
+ # Do we have Star Office installed?
+ my $configfilename = findsofficeconfigfile();
+ return 1 if !$configfilename;
+ $configfilename =~ m!^(.*)/share/xp3/Xpdefaults$!;
+ my $configprefix = $1;
+ # Load Star Office printer config file
+ my $configfilecontent = readsofficeconfigfile($configfilename);
+ # Update remote CUPS queues
+ if (($printer->{SPOOLER} eq "cups") &&
+ (-x "$prefix/usr/bin/curl")) {
+ my @printerlist = getcupsremotequeues();
+ for my $listentry (@printerlist) {
+ next if !($listentry =~ /^([^\|]+)\|([^\|]+)$/);
+ my $q = $1;
+ next if ($q ne $queue);
+ my $server = $2;
+ # Remove server name from queue name
+ $q =~ s/^([^@]*)@.*$/$1/;
+ eval(run_program::rooted
+ ($prefix, "/usr/bin/curl", "-o",
+ "/etc/foomatic/$queue.ppd",
+ "http://$server:631/printers/$q.ppd"));
+ # Does the file exist and is it not an error message?
+ if ((-r "$prefix/etc/foomatic/$queue.ppd") &&
+ (cat_("$prefix/etc/foomatic/$queue.ppd") =~
+ /^\*PPD-Adobe/)) {
+ $configfilecontent =
+ makestarofficeprinterentry($printer, $queue,
+ $configprefix,
+ $configfilecontent);
+ } else {
+ return 0;
+ }
+ last;
+ }
+ }
+ # Write back Star Office configuration file
+ return writesofficeconfigfile($configfilename, $configfilecontent);
+}
+
+sub addcupsremotetoopenoffice {
+ my ($printer, $queue) = @_;
+ # Do we have Open Office installed?
+ my $configfilename = findopenofficeconfigfile();
+ return 1 if !$configfilename;
+ $configfilename =~ m!^(.*)/share/psprint/psprint.conf$!;
+ my $configprefix = $1;
+ # Load Open Office printer config file
+ my $configfilecontent = readsofficeconfigfile($configfilename);
+ # Update remote CUPS queues
+ if (($printer->{SPOOLER} eq "cups") &&
+ (-x "$prefix/usr/bin/curl")) {
+ my @printerlist = getcupsremotequeues();
+ for my $listentry (@printerlist) {
+ next if !($listentry =~ /^([^\|]+)\|([^\|]+)$/);
+ my $q = $1;
+ next if ($q ne $queue);
+ my $server = $2;
+ # Remove server name from queue name
+ $q =~ s/^([^@]*)@.*$/$1/;
+ eval(run_program::rooted
+ ($prefix, "/usr/bin/curl", "-o",
+ "/etc/foomatic/$queue.ppd",
+ "http://$server:631/printers/$q.ppd"));
+ # Does the file exist and is it not an error message?
+ if ((-r "$prefix/etc/foomatic/$queue.ppd") &&
+ (cat_("$prefix/etc/foomatic/$queue.ppd") =~
+ /^\*PPD-Adobe/)) {
+ $configfilecontent =
+ makeopenofficeprinterentry($printer, $queue,
+ $configprefix,
+ $configfilecontent);
+ } else {
+ return 0;
+ }
+ }
+ }
+ # Write back Open Office configuration file
+ return writesofficeconfigfile($configfilename, $configfilecontent);
}
sub removeprinterfromstaroffice {
my ($printer, $queue) = @_;
# Do we have Star Office installed?
my $configfilename = findsofficeconfigfile();
- return 0 if !$configfilename;
+ return 1 if !$configfilename;
$configfilename =~ m!^(.*)/share/xp3/Xpdefaults$!;
my $configprefix = $1;
# Load Star Office printer config file
@@ -1744,14 +1839,14 @@ sub removeprinterfromstaroffice {
removestarofficeprinterentry($printer, $queue, $configprefix,
$configfilecontent);
# Write back Star Office configuration file
- writesofficeconfigfile($configfilename, $configfilecontent);
+ return writesofficeconfigfile($configfilename, $configfilecontent);
}
sub removeprinterfromopenoffice {
my ($printer, $queue) = @_;
# Do we have Open Office installed?
my $configfilename = findopenofficeconfigfile();
- return 0 if !$configfilename;
+ return 1 if !$configfilename;
$configfilename =~ m!^(.*)/share/psprint/psprint.conf$!;
my $configprefix = $1;
# Load Open Office printer config file
@@ -1761,7 +1856,45 @@ sub removeprinterfromopenoffice {
removeopenofficeprinterentry($printer, $queue, $configprefix,
$configfilecontent);
# Write back Open Office configuration file
- writesofficeconfigfile($configfilename, $configfilecontent);
+ return writesofficeconfigfile($configfilename, $configfilecontent);
+}
+
+sub removelocalprintersfromstaroffice {
+ my ($printer) = @_;
+ # Do we have Star Office installed?
+ my $configfilename = findsofficeconfigfile();
+ return 1 if !$configfilename;
+ $configfilename =~ m!^(.*)/share/xp3/Xpdefaults$!;
+ my $configprefix = $1;
+ # Load Star Office printer config file
+ my $configfilecontent = readsofficeconfigfile($configfilename);
+ # Remove the printer entries
+ for my $queue (keys(%{$printer->{configured}})) {
+ $configfilecontent =
+ removestarofficeprinterentry($printer, $queue, $configprefix,
+ $configfilecontent);
+ }
+ # Write back Star Office configuration file
+ return writesofficeconfigfile($configfilename, $configfilecontent);
+}
+
+sub removelocalprintersfromopenoffice {
+ my ($printer) = @_;
+ # Do we have Open Office installed?
+ my $configfilename = findopenofficeconfigfile();
+ return 1 if !$configfilename;
+ $configfilename =~ m!^(.*)/share/psprint/psprint.conf$!;
+ my $configprefix = $1;
+ # Load Open Office printer config file
+ my $configfilecontent = readsofficeconfigfile($configfilename);
+ # Remove the printer entries
+ for my $queue (keys(%{$printer->{configured}})) {
+ $configfilecontent =
+ removeopenofficeprinterentry($printer, $queue, $configprefix,
+ $configfilecontent);
+ }
+ # Write back Open Office configuration file
+ return writesofficeconfigfile($configfilename, $configfilecontent);
}
sub makestarofficeprinterentry {
@@ -1969,8 +2102,7 @@ sub findopenofficeconfigfile {
sub readsofficeconfigfile {
my ($file) = @_;
local *F;
- open F, "< $prefix$file" ||
- die "Could not read $file!\n";
+ open F, "< $prefix$file" || return "";
my $filecontent = join("", <F>);
close F;
return $filecontent;
@@ -1979,10 +2111,10 @@ sub readsofficeconfigfile {
sub writesofficeconfigfile {
my ($file, $filecontent) = @_;
local *F;
- open F, "> $prefix$file" ||
- die "Could not write $file!\n";
+ open F, "> $prefix$file" || return 0;
print F $filecontent;
close F;
+ return 1;
}
sub getcupsremotequeues {
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index b0c233504..29dd2417f 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -2095,11 +2095,13 @@ sub install_spooler {
if ((!$::testing) &&
(!printer::files_exist((qw(/usr/lib/cups/cgi-bin/printers.cgi
/sbin/ifconfig
- /usr/bin/xpp),
+ /usr/bin/xpp
+ /usr/bin/curl),
($::expert ?
"/usr/share/cups/model/postscript.ppd.gz" : ())
)))) {
$in->do_pkgs->install(('cups', 'net-tools', 'xpp',
+ 'curl',
($::expert ? 'cups-drivers' : ())));
}
# Start daemon
@@ -2223,6 +2225,8 @@ sub setup_default_spooler {
return;
}
if ($printer->{SPOOLER} ne $oldspooler) {
+ # Remove the local printers from Star Office/Open Office
+ printer::removelocalprintersfromapplications($printer);
# Get the queues of this spooler
{
my $w = $in->wait_message('', _("Reading printer data ..."));
@@ -2422,7 +2426,9 @@ sub main {
{title => _("Printerdrake"),
messages =>
($noprinters ? "" :
- _("The following printers are configured. Double-click on a printer to change its settings; to make it the default printer; or to view information about it.")),
+ (($printer->{SPOOLER} eq "cups") ?
+ _("The following printers are configured. Double-click on a printer to change its settings; to make it the default printer; to view information about it; or to make a printer on a remote CUPS server available for Star/Open Office.") :
+ _("The following printers are configured. Double-click on a printer to change its settings; to make it the default printer; or to view information about it."))),
cancel => (""),
ok => (""),
},
@@ -2733,6 +2739,9 @@ What do you want to modify on this printer?",
_("Printer options") : ())) : ()),
(($queue ne $printer->{DEFAULT}) ?
_("Set this printer as the default") : ()),
+ ($printer->{configured}{$queue} ? () :
+ (_("Add this printer to Star/Open Office"),
+ _("Remove this printer from Star/Open Office"))),
_("Print test pages"),
_("Know how to use this printer"),
($printer->{configured}{$queue} ?
@@ -2806,6 +2815,24 @@ What do you want to modify on this printer?",
printer::set_default_printer($printer);
$in->ask_warn(_("Default printer"),
_("The printer \"%s\" is set as the default printer now.", $queue));
+ } elsif ($modify eq _("Add this printer to Star/Open Office")) {
+ if (printer::addcupsremotetoapplications
+ ($printer, $queue)) {
+ $in->ask_warn(_("Adding printer to Star/Open Office"),
+ _("The printer \"%s\" was successfully added to Star/Open Office.", $queue));
+ } else {
+ $in->ask_warn(_("Adding printer to Star/Open Office"),
+ _("Failed to add the printer \"%s\" to Star/Open Office.", $queue));
+ }
+ } elsif ($modify eq _("Remove this printer from Star/Open Office")) {
+ if (printer::removeprinterfromapplications
+ ($printer, $queue)) {
+ $in->ask_warn(_("Removing printer from Star/Open Office"),
+ _("The printer \"%s\" was successfully removed from Star/Open Office.", $queue));
+ } else {
+ $in->ask_warn(_("Removing printer from Star/Open Office"),
+ _("Failed to remove the printer \"%s\" from Star/Open Office.", $queue));
+ }
} elsif ($modify eq _("Print test pages")) {
print_testpages($printer, $in, $upNetwork);
} elsif ($modify eq _("Know how to use this printer")) {