summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-11-13 15:33:36 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-11-13 15:33:36 +0000
commit20546649db339d6d4d8fea471ebccb158e10c5de (patch)
treed0c70f824b3e9c7b9bfbe6f82cbb58dd621f4176 /perl-install/printer
parent36facb03004c3db54dcf9c803d0a190b0b947cbb (diff)
downloaddrakx-20546649db339d6d4d8fea471ebccb158e10c5de.tar
drakx-20546649db339d6d4d8fea471ebccb158e10c5de.tar.gz
drakx-20546649db339d6d4d8fea471ebccb158e10c5de.tar.bz2
drakx-20546649db339d6d4d8fea471ebccb158e10c5de.tar.xz
drakx-20546649db339d6d4d8fea471ebccb158e10c5de.zip
don't reinvent the wheel, use common
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/gimp.pm74
1 files changed, 22 insertions, 52 deletions
diff --git a/perl-install/printer/gimp.pm b/perl-install/printer/gimp.pm
index bf4cab83c..5bf600e3d 100644
--- a/perl-install/printer/gimp.pm
+++ b/perl-install/printer/gimp.pm
@@ -109,9 +109,7 @@ sub addcupsremoteto {
return 0;
}
}
- } else {
- return 1;
- }
+ } else { return 1 }
# There is no system-wide config file, treat every user's config file
foreach my $configfilename (@configfilenames) {
# Load GIMP's printer config file
@@ -119,12 +117,9 @@ sub addcupsremoteto {
# Add the printer entry
if (!isprinterconfigured ($queue, $configfilecontent)) {
# Remove the old printer entry
- $configfilecontent =
- removeprinter($queue, $configfilecontent);
+ $configfilecontent = removeprinter($queue, $configfilecontent);
# Add the new printer entry
- $configfilecontent =
- makeprinterentry($printer, $queue,
- $configfilecontent);
+ $configfilecontent = makeprinterentry($printer, $queue, $configfilecontent);
}
# Write back GIMP's printer configuration file
writeconfigfile($configfilename, $configfilecontent);
@@ -142,8 +137,7 @@ sub removeprinterfrom {
# Load GIMP's printer config file
my $configfilecontent = readconfigfile($configfilename);
# Remove the printer entry
- $configfilecontent =
- removeprinter($queue, $configfilecontent);
+ $configfilecontent = removeprinter($queue, $configfilecontent);
# Write back GIMP's printer configuration file
writeconfigfile($configfilename, $configfilecontent);
}
@@ -161,8 +155,7 @@ sub removelocalprintersfrom {
my $configfilecontent = readconfigfile($configfilename);
# Remove the printer entries
foreach my $queue (keys(%{$printer->{configured}})) {
- $configfilecontent =
- removeprinter($queue, $configfilecontent);
+ $configfilecontent = removeprinter($queue, $configfilecontent);
}
# Write back GIMP's printer configuration file
writeconfigfile($configfilename, $configfilecontent);
@@ -200,29 +193,19 @@ sub makeprinterentry {
$configfile = addentry($queue,
"Media-Size: $papersize", $configfile);
}
- $configfile = removeentry($queue,
- "PPD-File:", $configfile);
- $configfile = addentry($queue,
- "PPD-File:", $configfile);
- $configfile = removeentry($queue,
- "Driver:", $configfile);
- $configfile = addentry($queue,
- "Driver: $gimpprintdriver", $configfile);
- $configfile = removeentry($queue,
- "Destination:", $configfile);
+ $configfile = removeentry($queue, "PPD-File:", $configfile);
+ $configfile = addentry($queue, "PPD-File:", $configfile);
+ $configfile = removeentry($queue, "Driver:", $configfile);
+ $configfile = addentry($queue, "Driver: $gimpprintdriver", $configfile);
+ $configfile = removeentry($queue, "Destination:", $configfile);
$configfile = addentry($queue,
"Destination: /usr/bin/$printer::data::lprcommand{$printer->{SPOOLER}{print_command}} -P $queue -o raw", $configfile);
} else {
- $configfile = removeentry($queue,
- "PPD-File:", $configfile);
- $configfile = addentry($queue,
- "PPD-File: /etc/foomatic/$queue.ppd", $configfile);
- $configfile = removeentry($queue,
- "Driver:", $configfile);
- $configfile = addentry($queue,
- "Driver: ps2", $configfile);
- $configfile = removeentry($queue,
- "Destination:", $configfile);
+ $configfile = removeentry($queue, "PPD-File:", $configfile);
+ $configfile = addentry($queue, "PPD-File: /etc/foomatic/$queue.ppd", $configfile);
+ $configfile = removeentry($queue, "Driver:", $configfile);
+ $configfile = addentry($queue, "Driver: ps2", $configfile);
+ $configfile = removeentry($queue, "Destination:", $configfile);
$configfile = addentry($queue,
"Destination: /usr/bin/$printer::data::lprcommand{$printer->{SPOOLER}{print_command}} -P $queue", $configfile);
}
@@ -247,22 +230,15 @@ sub findconfigfiles {
$dir =~ s,/[^/]*$,,;
next if (-f $dir) && (! -d $dir);
if (! -d "$::prefix$dir") {
- run_program::rooted($::prefix,
- "/bin/mkdir", $dir)
- or next;
- run_program::rooted($::prefix,
- "/bin/chown", "$uid.$gid", $dir)
- or next;
+ mkdir_p("$::prefix$dir") or next;
+ set_permissions("$::prefix$dir", "$uid.$gid") or next;
}
if (! -f "$::prefix$homedir/$file") {
local *F;
open F, "> $::prefix$homedir/$file" or next;
print F "#PRINTRCv1 written by GIMP-PRINT 4.2.2 - 13 Sep 2002\n";
close F;
- run_program::rooted($::prefix,
- "/bin/chown", "$uid.$gid",
- "$homedir/$file")
- or next;
+ set_permissions("$::prefix$homedir/$file", "$uid.$gid") or next;
}
push (@filestotreat, "$homedir/$file");
}
@@ -297,9 +273,7 @@ sub addentry {
my @lines = split("\n", $filecontent);
foreach (@lines) {
if (!$sectionfound) {
- if (/^\s*Printer\s*:\s*($section)\s*$/) {
- $sectionfound = 1;
- }
+ $sectionfound = 1 if /^\s*Printer\s*:\s*($section)\s*$/;
} else {
if (!/^\s*$/ && !/^\s*;/) { #-#
$_ = "$entry\n$_";
@@ -308,9 +282,7 @@ sub addentry {
}
}
}
- if ($sectionfound && !$entryinserted) {
- push(@lines, $entry);
- }
+ push(@lines, $entry) if $sectionfound && !$entryinserted;
return join ("\n", @lines);
}
@@ -319,10 +291,8 @@ sub addprinter {
my $entryinserted = 0;
my @lines = split("\n", $filecontent);
foreach (@lines) {
- if (/^\s*Printer\s*:\s*($section)\s*$/) {
- # section already there, nothing to be done
- return $filecontent;
- }
+ # section already there, nothing to be done
+ return $filecontent if /^\s*Printer\s*:\s*($section)\s*$/;
}
return $filecontent . "\nPrinter: $section";
}
419' href='#n419'>419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
package scanner;
# scanner.pm $Id$
# Yves Duret <yduret at mandrakesoft.com>
# Till Kamppeter <till at mandrakesoft.com>
# Copyright (C) 2001-2004 MandrakeSoft
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# pbs/TODO: