/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* DoPrinterAdd class
* Worker class for adding local and remote printers.
*/
public class DoPrinterAdd {
//
// Set attributes for testing
//
p.setPrinterName("javatest");
p.setPrinterType("PS");
p.setPrintServer("zelkova");
p.setComment("This is a comment");
p.setNotify("none");
p.setProtocol("bsd");
p.setDestination(null);
p.setIsDefaultPrinter(false);
p.setBanner("never");
p.setEnable(true);
p.setAccept(true);
try {
}
catch (Exception e)
{
}
}
//
// Interface to Printer object.
//
public static void add(
Printer p,
{
} else {
}
return;
}
//
// Do the work of adding a local printer.
//
private static void addLocal(
Printer p,
{
int exitvalue = 0;
// Since it's local set extensions.
// Eventually the gui should do this.
p.setExtensions("Solaris");
boolean default_printer = p.getIsDefaultPrinter();
//
// "uri" is a pseudo protocol and means that the device is
// specified in the destination.
//
destination = null;
}
}
if (printserver != null)
else {
if (destination != null)
else
}
}
if (printertype != null)
}
if (destination != null)
}
} else {
}
}
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
} else {
p.setWarnLog(err);
}
//
// lpadmin won't take allow and deny lists together
// so do the deny seperately.
//
}
" -u deny:" + tmpstr;
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
//
// Have to use a command array here since
// exec(String) doesn't parse quoted strings.
//
"-D", comment };
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
// If this is the default printer set it.
// If it fails warn user.
if (default_printer) {
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
// Check to see if we should enable it.
// If it fails warn user.
if (enable) {
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
// Check to see if we should accept it.
// If it fails warn user.
if (accept) {
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
doFilters(p);
//
// Take care of name service now.
//
try {
}
catch (Exception e) {
p.clearLogs();
//
// Back out the local printer.
//
try {
}
}
p.clearLogs();
throw (e);
}
}
return;
}
//
// Do the work of adding a remote printer.
//
private static void addRemote(
Printer p,
{
int exitvalue = 0;
boolean default_printer = p.getIsDefaultPrinter();
boolean isnismaster = false;
//
// Find out if we are the nis master
//
isnismaster = true;
h = null;
}
//
// If the name service is not system and we are
// not the nis master then do the name service
// update and return.
//
return;
}
}
//
// Fix up cmd so we can log it.
//
continue;
if (i == 6) {
continue;
}
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
}
p.setWarnLog(err);
}
// If this is the default printer set it.
// If it fails warn user.
if (default_printer) {
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
//
// If it's nis and we are here then we are the nis
// master. This call will do the make for us.
//
try {
}
catch (Exception e) {
p.clearLogs();
try {
//
// Back out the local printer.
//
}
{
}
p.clearLogs();
throw e;
}
}
return;
}
//
// Configure filters
// already been configured. We'll add warning messages if
// there are problems but don't consider anything here fatal.
//
{
int i = 0;
int j = 0;
//
// Get list of potential filters
//
syscmd = new SysCommand();
return;
}
if (o == null) {
return;
}
return;
}
}
//
// Remove .fd suffix and empty slots that aren't filters.
//
} else {
psfilters[i] = "";
}
}
// Get list of currently configured filters
syscmd = new SysCommand();
o = null;
p.setWarnLog(err);
}
return;
} else {
}
continue;
// If we have filters see if this one is
// already configured.
if (o != null) {
continue;
}
// Add the filter
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
}
}
}