/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* DoPrinterMod class
* Worker class for modifying a printer.
*/
public class DoPrinterMod {
//
// main for testing
//
p.setPrinterName("javatest");
p.setPrinterType("hplaser");
p.setPrintServer("zelkova");
p.setComment("This is a new comment");
p.setNotify("none");
p.setProtocol("bsd");
p.setDestination("");
p.setIsDefaultPrinter(true);
p.setBanner("never");
p.setEnable(true);
p.setAccept(false);
p.setFileContents(arr);
p.setUserAllowList(arr);
p.setUserDenyList(arr);
try {
}
catch (Exception e)
{
}
}
//
// Interface to Printer object.
//
public static void modify(
Printer p,
{
try {
}
catch (Exception e) {
p.setErrorLog(err);
throw new pmCmdFailedException(err);
}
if (islocal) {
} else {
}
return;
}
//
// Do the work of modifying a local printer.
//
private static void modifyLocal(
Printer p,
{
// Since it's local set extensions
// Eventually the gui should do this.
p.setExtensions("Solaris");
boolean default_printer = false;
boolean enable = false;
boolean accept = false;
boolean isURI = false;
boolean allow_changed = false;
boolean default_printer_changed = false;
boolean banner_req_changed = false;
boolean enable_changed = false;
boolean accept_changed = false;
//
// Set the things that have changed.
//
printertype = p.getPrinterType();
comment = p.getComment();
// Comment changed to empty.
p.setComment("");
comment = "";
}
}
protocol = p.getProtocol();
}
// Need to know if the new protocol is uri or if the
// protocol did not change and the current one is uri
isURI = true;
}
destination = p.getDestination();
}
default_printer_changed = true;
}
enable_changed = true;
}
default_printer_changed = true;
}
enable_changed = true;
}
default_printer_changed = true;
}
enable_changed = true;
}
accept_changed = true;
}
banner_req_changed = true;
}
file_contents = p.getFileContents();
allow_changed = true;
// If the current value is "none" and the new
// value is null nothing is changing.
if (p.getUserAllowList() == null) {
allow_changed = false;
}
}
}
}
allow_changed = true;
}
if (allow_changed) {
user_allow_list = p.getUserAllowList();
user_deny_list = p.getUserDenyList();
}
//
// Return if nothing changed.
//
if ((printertype == null) &&
(destination == null) &&
(file_contents == null) &&
(!allow_changed) &&
(!default_printer_changed) &&
(!enable_changed) &&
(!accept_changed) &&
(!banner_req_changed)) {
return;
}
// If this is the default printer set it.
if (default_printer_changed) {
if (default_printer) {
} else {
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
}
//
// If this is only a default printer change then possibly
// update the name service and return.
if ((printertype == null) &&
(destination == null) &&
(file_contents == null) &&
(!allow_changed) &&
(!enable_changed) &&
(!accept_changed) &&
(!banner_req_changed)) {
return;
}
p.modhints = "defaultonly";
p.modhints = "";
return;
}
//
//
if (enable_changed) {
if (p.getEnable() == true) {
} else {
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
}
if (accept_changed) {
if (p.getAccept() == true) {
} else {
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
}
//
// Do some slight of hand to deal with overloading of destination
// with device for uri protocol
// properties of the queue
if (isURI) {
if (destination != null)
else
destination = null;
} else {
}
}
//
// Build the modify command
//
if (printername != null)
}
}
// Network printer
if (isURI) {
else
}
if (printertype != null)
}
// destination is overloaded to hold uri device for network printers
// if the protocol is uri, don't set either destination or protocol
// the device has been set to the destination above
if (isURI) {
} else {
if (destination != null)
}
}
}
if (banner_req_changed) {
}
}
//
// Has any of the above changed.
//
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
}
//
// If the user allow list changed delete all then re-add
//
if (allow_changed) {
" -u allow:none";
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
if ((user_deny_list != null) &&
+ user_deny_list[i]);
}
" -u deny:" + tmpstr;
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
}
if ((user_allow_list != null) &&
+ user_allow_list[i]);
}
" -u allow:" + tmpstr;
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
}
}
//
// Have to use a command array here since
// exec(String) doesn't parse quoted strings.
// Use lpadmin so the comment in /etc/printers.conf
//
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
p.setWarnLog(err);
}
//
// LPADMIN BUG. Comment not cleared in printers.conf
// so force it with lpset.
//
syscmd = new SysCommand();
p.setWarnLog(err);
}
}
}
//
// Return if we don't need to touch the name service.
//
return;
}
return;
}
return;
}
//
// Do the work of modifying a remote printer.
//
private static void modifyRemote(
Printer p,
{
int exitvalue = 0;
boolean default_printer = false;
boolean default_printer_changed = false;
printername = p.getPrinterName();
printserver = p.getPrintServer();
comment = p.getComment();
// The comment changed to empty.
p.setComment("");
comment = "";
}
}
//
// Don't support extensions in the gui yet.
// If they exist leave them alone.
// EXTENSIONS
extensions = p.getExtensions();
default_printer_changed = true;
}
//
// Return if nothing changed.
//
if ((printserver == null) &&
(extensions == null) &&
(!default_printer_changed)) {
return;
}
//
// If this is only a default printer change then set modhints
//
if ((printserver == null) &&
(extensions == null) &&
p.modhints = "defaultonly";
}
//
// Find out if we are the nis master
//
boolean isnismaster = false;
isnismaster = true;
h = null;
}
//
// If we are not updating system and we are not the nis
// master then update the name service and return.
//
p.modhints = "";
return;
}
p.modhints = "";
//
// Take care of the bsdaddr attribute
//
// EXTENSIONS
// The gui doesn't support extensions yet so the goal
// here is to prepare for it but don't actually
// modify them.
//
// If printserver is null we are changing
// extensions. Set printserver to its current
// value.
if (printserver == null) {
}
+ printername;
//
// Leave the extensions alone
// EXTENSIONS
//
if (extensions != null) {
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
}
p.setWarnLog(err);
}
}
" " + printername;
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
}
p.setWarnLog(err);
}
}
// If this is the default printer set it.
if (default_printer_changed) {
if (default_printer) {
} else {
}
syscmd = new SysCommand();
p.setErrorLog(err);
throw new pmCmdFailedException(err);
}
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.
//
}
return;
}
{
return (true);
}
return (false);
}
return (false);
}
int i, j;
boolean found;
found = false;
found = true;
}
}
if (found == false) {
return (false);
}
}
return (true);
}
{
return (true);
}
return (false);
}
}
}