/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Remind: This class uses solaris commands. We also need a linux
* version
*/
implements BackgroundServiceLookup, Runnable {
/* Remind: the current implementation is static, as its assumed
* its preferable to minimise creation of PrintService instances.
* will take a hit of needing to regather the list of services.
*/
private static boolean pollServices = true;
static {
/* The system property "sun.java2d.print.polling"
* can be used to force the printing code to poll or not poll
* for PrintServices.
*/
pollServices = true;
pollServices = false;
}
}
/* The system property "sun.java2d.print.minRefreshTime"
* can be used to specify minimum refresh time (in seconds)
* for polling PrintServices. The default is 120.
*/
"sun.java2d.print.minRefreshTime"));
if (refreshTimeStr != null) {
try {
} catch (NumberFormatException e) {
}
if (minRefreshTime < DEFAULT_MINREFRESH) {
}
}
}
static boolean isMac() {
}
static boolean isSysV() {
}
static boolean isBSD() {
}
};
};
"| grep : | sed -ne 's/://p'",
"| grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}'"
};
static int getBSDCommandIndex() {
return BSD_LPD_NG;
}
return BSD_LPD_NG;
}
}
return BSD_LPD;
}
public UnixPrintServiceLookup() {
// start the printer listener thread
if (pollServices) {
}
}
/* Want the PrintService which is default print service to have
* equality of reference with the equivalent in list of print services
* This isn't required by the API and there's a risk doing this will
* lead people to assume its guaranteed.
*/
}
}
if (printServices == null) {
return new PrintService[0];
} else {
return printServices;
}
}
// refreshes "printServices"
public synchronized void refreshServices() {
/* excludes the default printer */
if (CUPSPrinter.isCupsRunning()) {
}
}
} else {
} else { //BSD
}
}
if (defaultPrintService != null) {
} else {
}
return;
}
int defaultIndex = -1;
continue;
}
if ((defaultPrintService != null)
} else {
if (printServices == null) {
if (CUPSPrinter.isCupsRunning()) {
try {
printerURIs[p],
true));
} catch (Exception e) {
" getAllPrinters Exception "+
e);
}
} else {
}
} else {
int j;
if ((printServices[j] != null) &&
printServices[j] = null;
break;
}
}
if (CUPSPrinter.isCupsRunning()) {
try {
printers[p],
printerURIs[p],
true));
} catch (Exception e) {
" getAllPrinters Exception "+
e);
}
} else {
}
}
}
}
}
// Look for deleted services and invalidate these
if (printServices != null) {
if ((printServices[j] instanceof UnixPrintService) &&
}
}
}
//if defaultService is not found in printerList
//add default to the list
}
new PrintService[] {});
// swap default with the first in the list
if (defaultIndex > 0) {
}
}
return false;
}
}
return true;
}
/* This checks for validity of the printer name before passing as
* parameter to a shell command.
*/
char c;
for (int i=0; i < s.length(); i++) {
c = s.charAt(i);
if (Character.isLetterOrDigit(c) ||
c == '-' || c == '_' || c == '.' || c == '/') {
continue;
} else {
return false;
}
}
return true;
}
/* On a network with many (hundreds) of network printers, it
* can save several seconds if you know all you want is a particular
* printer, to ask for that printer rather than retrieving all printers.
*/
return null;
}
/* check is all printers are already available */
if (printServices != null) {
return printService;
}
}
}
/* take CUPS into account first */
if (CUPSPrinter.isCupsRunning()) {
try {
return new IPPPrintService(name,
new URL("http://"+
name));
} catch (Exception e) {
" getServiceByName Exception "+
e);
}
}
/* fallback if nothing not having a printer at this point */
} else {
}
return printer;
}
private PrintService[]
return getPrintServices();
}
/* Typically expect that if a service attribute is specified that
* its a printer name and there ought to be only one match.
* Directly retrieve that service and confirm
* that it meets the other requirements.
* If printer name isn't mentioned then go a slow path checking
* all printers if they meet the reqiremements.
*/
/* To avoid execing a unix command see if the client is asking
* for the default printer by name, since we already have that
* initialised.
*/
return services;
} else {
return new PrintService[0];
}
} else {
/* Its not the default service */
return services;
} else {
return new PrintService[0];
}
}
} else {
/* specified service attributes don't include a name.*/
services = getPrintServices();
}
}
}
return services;
}
}
/*
* If service attributes are specified then there must be additional
* filtering.
*/
}
requestSet = new HashPrintRequestAttributeSet();
serviceSet = new HashPrintServiceAttributeSet();
if (attrs[i] instanceof PrintRequestAttribute) {
} else if (attrs[i] instanceof PrintServiceAttribute) {
}
}
}
return services;
}
if (CUPSPrinter.isCupsRunning()) {
try {
if (services[i].
}
} catch (IllegalArgumentException e) {
}
}
} else {
// We only need to compare 1 PrintService because all
// UnixPrintServices are the same anyway. We will not use
// default PrintService because it might be null.
{
return services;
} else {
return new PrintService[0];
}
}
}
/*
* return empty array as don't support multi docs
*/
public MultiDocPrintService[]
}
return new MultiDocPrintService[0];
}
}
// clear defaultPrintService
(CUPSPrinter.isCupsRunning()));
if (CUPSPrinter.isCupsRunning()) {
} else {
} else {
}
}
if (defaultPrinter == null) {
return null;
}
if (printServices != null) {
break;
}
}
}
if (defaultPrintService == null) {
if (CUPSPrinter.isCupsRunning()) {
try {
new URL("http://"+
} catch (Exception e) {
}
} else {
}
}
return defaultPrintService;
}
public synchronized void
if (printServices != null) {
} else {
if (lookupListeners == null) {
lookupListeners = new Vector();
} else {
}
}
}
/* This method isn't used in most cases because we rely on code in
* javax.print.PrintServiceLookup. This is needed just for the cases
* where those interfaces are by-passed.
*/
return inArr;
} else {
return outArr;
}
}
public void run() {
synchronized (this) {
listener =
}
}
}
if (cmdIndex == UNINITIALIZED) {
}
return null;
}
if ((cmdIndex==BSD_LPD_NG) &&
return null;
}
return names[0];
}
if (cmdIndex == UNINITIALIZED) {
}
return null;
}
return new UnixPrintService(name);
}
if (cmdIndex == UNINITIALIZED) {
}
return null;
}
return names;
}
return defaultPrinter;
} else {
return null;
} else {
return null;
} else {
return name;
}
}
}
}
return null;
} else {
return new UnixPrintService(name);
}
}
String command = "/usr/bin/lpstat -v|/usr/bin/expand|/usr/bin/cut -f3 -d' ' |/usr/bin/cut -f1 -d':' | /usr/bin/sort";
}
}
}
try {
if (isSysV()) {
} else {
}
new PrivilegedExceptionAction() {
try {
boolean done = false; // in case of interrupt.
while (!done) {
try {
done = true;
} catch (InterruptedException e) {
}
}
!= null) {
}
return results;
}
} finally {
f.delete();
// promptly close all streams.
if (bufferedReader != null) {
}
}
return null;
}
});
} catch (PrivilegedActionException e) {
}
return new String[0];
} else {
}
}
public void run() {
int refreshSecs;
while (true) {
try {
break;
}
if ((printServices != null) &&
// compute new refresh time 1 printer = 1 sec
} else {
}
try {
} catch (InterruptedException e) {
break;
}
}
}
}
}