diff options
-rw-r--r-- | perl-install/printer/cups.pm | 16 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 38 |
2 files changed, 39 insertions, 15 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm index 468625d65..ab9e28b21 100644 --- a/perl-install/printer/cups.pm +++ b/perl-install/printer/cups.pm @@ -77,6 +77,22 @@ sub lpstat_v() { } run_program::rooted_get_stdout($::prefix, 'lpstat', '-v'); } +sub lpinfo_v() { + map { + if (my ($type, $uri) = m/^\s*(\S+)\s+(\S+)\b/) { + if ($uri =~ m!:/!) { + $uri; + } elsif ($type =~ m/network/i) { + "$uri://"; + } else { + "$uri:/"; + } + } else { + (); + } + } run_program::rooted_get_stdout($::prefix, 'lpinfo', '-v'); +} + sub read_printer_list { my ($printer) = @_; # This function reads in a list of all printers which the local CUPS diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 45762f1d9..d1944400d 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -512,7 +512,7 @@ Printers on remote CUPS servers do not need to be configured here; these printer list => \@printertypes, not_edit => 1, sort => 0, type => 'list' }, - { text => N("Printer auto-detection (Local, TCP/Socket, and SMB printers)"), + { text => N("Printer auto-detection (Local, TCP/Socket, SMB printers, and device URI)"), type => 'bool', val => \$autodetect } ] ) or return 0; @@ -1693,24 +1693,32 @@ sub setup_uri { my ($printer, $in, $upNetwork) = @_; # $in->set_help('setupURI') if $::isInstall; + if ($printer->{AUTODETECT} and ($printer->{SPOOLER} eq 'cups')) { + my $_w = $in->wait_message(N("Printerdrake"), + N("Refreshing Device URI list...")); + printer::services::restart("cups"); + } return if !$in->ask_from(N("Printer Device URI"), N("You can specify directly the URI to access the printer. The URI must fulfill either the CUPS or the Foomatic specifications. Note that not all URI types are supported by all the spoolers."), [ { label => N("Printer Device URI"), val => \$printer->{currentqueue}{connect}, -list => [ $printer->{currentqueue}{connect}, - "parallel:/", - "usb:/", - "serial:/", - "http://", - "ipp://", - "lpd://", - "smb://", - "ncp://", - "socket://", - "ptal:/mlc:", - "ptal:/hpjd:", - "file:/", - 'postpipe:""', +list => [ if_($printer->{currentqueue}{connect}, + $printer->{currentqueue}{connect}), + ($printer->{SPOOLER} eq 'cups' ? + printer::cups::lpinfo_v() : + ("parallel:/", + "usb:/", + "serial:/", + "http://", + "ipp://", + "lpd://", + "smb://", + "ncp://", + "socket://", + "ptal:/mlc:", + "ptal:/hpjd:", + "file:/", + 'postpipe:""')), ], not_edit => 0, sort => 0 }, ], complete => sub { unless ($printer->{currentqueue}{connect} =~ /[^:]+:.+/) { |