diff options
Diffstat (limited to 'usr/src/cmd/print')
178 files changed, 0 insertions, 36376 deletions
diff --git a/usr/src/cmd/print/Makefile b/usr/src/cmd/print/Makefile deleted file mode 100644 index c22b11279c..0000000000 --- a/usr/src/cmd/print/Makefile +++ /dev/null @@ -1,106 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# cmd/print/Makefile -# - -include ../Makefile.cmd - -JAVA_SUBDIRS = printmgr - -PRINT_SUBDIRS = \ - scripts \ - lpget \ - lpset \ - conv_fix \ - printer-info \ - ppdmgr \ - selector \ - bsd-sysv-commands - -SUBDIRS = $(PRINT_SUBDIRS) $(JAVA_SUBDIRS) - -ROOTDIRS = $(ROOTLIB)/print - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -strip := TARGET= strip -_msg := TARGET = _msg - -# For testing message catalogs -_msg_test:= TARGET = _msg_test - -POFILE= print.po - -.KEEP_STATE: - -all install: $(ROOTDIRS) $(SUBDIRS) - -# -# We define our own definition for _msg here because most of these -# commands have the same PROG names as their counterparts in -# cmd/lp. Using the _msg rule defined in Makefile.cmd would -# result in clobbering the cmd/lp message files. -# To get around this we will define one message file "print.po" -# for these commands (except java printmgr). To build -# this file we find all of the .c files and run xgettext on them. -# Then concatenate this with the scripts.po file. -# -_msg: $(MSGDOMAIN) scripts $(JAVA_SUBDIRS) - @$(RM) $(POFILE) - $(XGETTEXT) -s `/bin/find . -type d -name SCCS -prune -o -type f -name '*.c' -print` - @/bin/cat messages.po scripts/scripts.po | sed '/domain/d' > $(POFILE) - @$(RM) messages.po - $(RM) $(MSGDOMAIN)/$(POFILE) - /bin/cp $(POFILE) $(MSGDOMAIN) - -# -# Create a message file to test with. -# -_msg_test: scripts - @$(RM) $(POFILE) - $(XGETTEXT) -s -m "xxx" `/bin/find . -print | grep '\.c$$' | sed '/SCCS/d'` - @/bin/cat messages.po scripts/scripts.po | sed '/domain/d' > $(POFILE) - echo 'domain "SUNW_OST_OSCMD"' > SUNW_OST_OSCMD.po - cat $(POFILE) >> SUNW_OST_OSCMD.po - msgfmt SUNW_OST_OSCMD.po - @$(RM) messages.po $(POFILE) SUNW_OST_OSCMD.po - -clean strip cstyle lint: $(SUBDIRS) - -clobber: $(SUBDIRS) - $(RM) $(POFILE) $(CLOBBERFILES) - -$(ROOTDIRS) $(MSGDOMAIN): - $(INS.dir) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/print/Makefile.sp b/usr/src/cmd/print/Makefile.sp deleted file mode 100644 index ebf97b53c6..0000000000 --- a/usr/src/cmd/print/Makefile.sp +++ /dev/null @@ -1,105 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/print/Makefile.sp -# Common makefile definitions (should be) used by all print(lp) makefiles -# - -include $(SRC)/cmd/Makefile.cmd - -LPROOT= $(SRC)/cmd/lp -NPRTROOT= $(LPROOT) -ROOTVAR= $(ROOT)/var -ROOTVARSP= $(ROOT)/var/spool -ROOTVARSPOOLPRINT= $(ROOTVARSP)/print - -ROOTINIT_D= $(ROOTETC)/init.d -ROOTRC0_D= $(ROOTETC)/rc0.d -ROOTRCS_D= $(ROOTETC)/rcS.d -ROOTRC1_D= $(ROOTETC)/rc1.d -ROOTRC2_D= $(ROOTETC)/rc2.d - - -ROOTETCLP= $(ROOTETC)/lp -ROOTLIBLP= $(ROOTLIB)/lp -ROOTBINLP= $(ROOTBIN)/lp -ROOTLIBLPPOST = $(ROOTLIBLP)/postscript -ROOTLOCALLP= $(ROOTLIBLP)/local -ROOTLIBPRINT= $(ROOTLIB)/print -ROOTLIBPRINTBIN= $(ROOTLIBPRINT)/bin - -ROOTUSRUCB= $(ROOT)/usr/ucb - - -# -# $(EMODES): Modes for executables -# $(SMODES): Modes for setuid executables -# $(DMODES): Modes for directories -# -EMODES = 0555 -SMODES = 04555 -DMODES = 0755 - - -INC = $(ROOT)/usr/include -INCSYS = $(INC)/sys - -LPINC = $(SRC)/include -#NPRTINC = $(NPRTROOT)/include -NPRTINC = $(SRC)/lib/print/libprint/common -LPLIB = $(SRC)/lib -LDLIBS += -L$(LPLIB) - - -LIBNPRT = -L$(ROOT)/usr/lib -lprint - -# lint definitions - -LINTFLAGS += -L $(SRC)/lib/print -lprint -lnsl -lsocket - -all :=TARGET= all -install :=TARGET= install -clean :=TARGET= clean -clobber :=TARGET= clobber -lint :=TARGET= lint -strip :=TARGET= strip -_msg :=TARGET= _msg - -ROOTLIBLPPROG= $(PROG:%=$(ROOTLIBLP)/%) -ROOTBINLPPROG= $(PROG:%=$(ROOTBINLP)/%) -ROOTETCLPPROG= $(PROG:%=$(ROOTETCLP)/%) -ROOTUSRUCBPROG= $(PROG:%=$(ROOTUSRUCB)/%) -ROOTLOCALLPPROG= $(PROG:%=$(ROOTLOCALLP)/%) -ROOTLIBLPPOSTPROG= $(PROG:%=$(ROOTLIBLPPOST)/%) -ROOTLIBPRINTPROG= $(PROG:%=$(ROOTLIBPRINT)/%) - -$(ROOTLIBLP)/% \ -$(ROOTBINLP)/% \ -$(ROOTETCLP)/% \ -$(ROOTUSRUCB)/% \ -$(ROOTLOCALLP)/% \ -$(ROOTLIBLPPOST)/% \ -$(ROOTLIBPRINT)/% : % - $(INS.file) diff --git a/usr/src/cmd/print/bsd-sysv-commands/Makefile b/usr/src/cmd/print/bsd-sysv-commands/Makefile deleted file mode 100644 index ee6131c805..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -include ../Makefile.sp - -UCBPROGS = lpr lpq lprm lpc -BINPROGS = lp lpstat cancel enable disable $(UCBPROGS) -SBINPROGS = accept reject lpmove - -LIBPRINTPROGS = in.lpd - -LIBLPPROGS = $(BINPROGS) $(SBINPROGS) - - -OBJS = $(BINPROGS:=.o) $(SBINPROGS:=.o) $(LIBPRINTPROGS:=.o) common.o - -ROOTLIBLPBIN=$(ROOTLIBLP)/bin - -ROOTBINPROGS = $(BINPROGS:%=$(ROOTBIN)/%) -ROOTUSRSBINPROGS = $(SBINPROGS:%=$(ROOTUSRSBIN)/%) -ROOTLIBPRINTPROGS = $(LIBPRINTPROGS:%=$(ROOTLIBPRINT)/%) -ROOTLIBLPPROGS = $(LIBLPPROGS:%=$(ROOTLIBLPBIN)/%) - - -FILEMODE = 0555 - -include ../../Makefile.cmd - -MANIFEST= rfc1179.xml -ROOTMANIFESTDIR= $(ROOTSVCAPPLICATIONPRINT) -$(ROOTMANIFEST) := FILEMODE= 444 - -LPLIB = $(SRC)/cmd/lp/lib -LIBLP = $(LPLIB)/lp/liblp.a -CFLAGS += $(CCVERBOSE) -CPPFLAGS += -I. -CPPFLAGS += -I../../../lib/print/libpapi-common/common -CPPFLAGS += -I$(ROOT)/usr/include -CPPFLAGS += -I../../lp/include -LDLIBS += $(LIBLP) -lpapi -lc -in.lpd:= CFLAGS += -DSOLARIS_PRIVATE_POST_0_9 -in.lpd:= LDLIBS += -lnsl -lsocket - -CERRWARN += -_gcc=-Wno-unused-variable -CERRWARN += -_gcc=-Wno-uninitialized - -all: $(BINPROGS) $(SBINPROGS) - -# each program needs common.o as well -$(BINPROGS) $(SBINPROGS) $(LIBPRINTPROGS): $(BINPROGS:%=%.c) $(SBINPROGS:%=%.c) $(LIBPRINTPROGS:%=%.c) common.o - $(LINK.c) -o $@ $@.c common.o $(LDLIBS) - $(POST_PROCESS) - -# ucb links (lptest is handled in usr/src/cmd/lp/cmd/Makefile) -ROOTUSRUCB = $(ROOT)/usr/ucb -ROOTUCBSYMLINKS = $(UCBPROGS:%=$(ROOTUSRUCB)/%) -$(ROOTUSRUCB)/%: $(ROOTUSRUCB) % - -$(ROOTLIBLPBIN)/%: % - $(INS.file) - -$(ROOTUCBSYMLINKS): - $(RM) $@; $(SYMLINK) ../bin/$(@F) $@ - -# usr/lib links -ROOTUSRLIBSYMLINKS = $(SBINPROGS:%=$(ROOTLIB)/%) -$(ROOTLIB)/%: $(ROOTLIB) % - -$(ROOTUSRLIBSYMLINKS): - $(RM) $@; $(SYMLINK) ../sbin/$(@F) $@ - -.KEEP_STATE: - -install: $(ROOTLIBLPPROGS) \ - $(ROOTLIBPRINT) $(ROOTLIBPRINTPROGS) $(ROOTMANIFEST) \ - $(ROOTUCBSYMLINKS) $(ROOTUSRLIBSYMLINKS) - -check: $(CHKMANIFEST) - -clean: - $(RM) $(OBJS) - -CLOBBERFILES += $(BINPROGS) $(SBINPROGS) $(LIBPRINTPROGS) - -lint: - -include ../../Makefile.targ diff --git a/usr/src/cmd/print/bsd-sysv-commands/accept.c b/usr/src/cmd/print/bsd-sysv-commands/accept.c deleted file mode 100644 index 74f392c9c3..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/accept.c +++ /dev/null @@ -1,117 +0,0 @@ - -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: accept.c 146 2006-03-24 00:26:54Z njacobs $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s destination ...\n"), - name); - exit(1); -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int exit_status = 0; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "E")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_ALWAYS; - break; - default: - usage(av[0]); - } - - if (ac == optind) - usage(av[0]); - - for (c = optind; c < ac; c++) { - char *printer = av[c]; - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit_status = 1; - } - - status = papiPrinterResume(svc, printer); - if (status == PAPI_OK) { - printf(gettext( - "Destination \"%s\" now accepting requests\n"), - printer); - } else if (status == PAPI_NOT_ACCEPTING) { - fprintf(stderr, gettext( - "Destination \"%s\" was already " - "accepting requests.\n"), printer); - exit_status = 1; - } else { - if (status == PAPI_OPERATION_NOT_SUPPORTED) { - fprintf(stderr, - verbose_papi_message(svc, status)); - } else { - fprintf(stderr, gettext("accept: %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit_status = 1; - } - } - - papiServiceDestroy(svc); - } - - return (exit_status); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/cancel.c b/usr/src/cmd/print/bsd-sysv-commands/cancel.c deleted file mode 100644 index 23359d9b5e..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/cancel.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - * - */ - -/* $Id: cancel.c 147 2006-04-25 16:51:06Z njacobs $ */ - - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, "Usage: %s [-u user] (printer|request-id ...)\n", name); - exit(1); -} - -static int32_t -get_job_id_requested(papi_job_t job) { - int32_t rid = -1; - - papi_attribute_t **list = papiJobGetAttributeList(job); - papiAttributeListGetInteger(list, NULL, - "job-id-requested", &rid); - - return (rid); -} - -int -cancel_jobs_for_user(char *user, papi_encryption_t encryption, char *pname) { - - papi_status_t status; - papi_service_t svc = NULL; - char **printers = NULL; - int i, exit_code; - - if (pname == NULL) { - status = papiServiceCreate(&svc, NULL, NULL, NULL, - cli_auth_callback, encryption, NULL); - printers = interest_list(svc); - papiServiceDestroy(svc); - } else { - list_append(&printers, strdup(pname)); - } - - if (printers == NULL) - exit(0); - - for (i = 0; printers[i] != NULL; i++) { - char *printer = printers[i]; - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit(1); - } - exit_code = berkeley_cancel_request(svc, stdout, printer, 1, - &user); - - papiServiceDestroy(svc); - if (exit_code != 0) - break; - } - free(printers); - return (exit_code); -} - -int -main(int ac, char *av[]) -{ - int exit_code = 0; - char *user = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int c; - int32_t rid = -1; - int first_dest = 0; - - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - if (ac == 1) - usage(av[0]); - - while ((c = getopt(ac, av, "Eu:")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - case 'u': - user = optarg; - break; - default: - usage(av[0]); - } - - for (c = optind; c < ac; c++) { - papi_status_t status; - papi_service_t svc = NULL; - papi_job_t *jobs = NULL; - char *printer = NULL; - int32_t id = -1; - - status = papiServiceCreate(&svc, av[c], NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - if (first_dest == 0) { - (void) get_printer_id(av[c], &printer, &id); - status = papiServiceCreate(&svc, printer, NULL, - NULL, cli_auth_callback, encryption, NULL); - } - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, - verbose_papi_message(svc, status)); - exit(1); - } - } else { - first_dest = 1; - printer = av[c]; - } - -#define OUT ((status == PAPI_OK) ? stdout : stderr) - - if (id != -1) { /* it's a job */ - char *mesg = gettext("cancelled"); - - /* - * Check if the job-id is job-id-requested - * or job-id. If it is job-id-requested then find - * corresponding job-id and send it to cancel - */ - rid = job_to_be_queried(svc, printer, id); - if (rid < 0) { - /* - * Either it is a remote job which cannot be - * cancelled based on job-id or job-id is - * not found - */ - exit_code = 1; - fprintf(OUT, "%s-%d: %s\n", - printer, id, gettext("not-found")); - } else { - status = papiJobCancel(svc, printer, rid); - if (status == PAPI_NOT_AUTHORIZED) { - mesg = papiStatusString(status); - exit_code = 1; - } else if (status != PAPI_OK) { - mesg = gettext( - verbose_papi_message( - svc, status)); - exit_code = 1; - } - fprintf(OUT, "%s-%d: %s\n", printer, id, mesg); - } - - } else { /* it's a printer */ - if (user == NULL) { - - /* Remove first job from printer */ - - status = papiPrinterListJobs(svc, printer, - NULL, NULL, 0, &jobs); - - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "ListJobs %s: %s\n"), printer, - verbose_papi_message(svc, status)); - exit_code = 1; - } - - if (jobs != NULL && *jobs != NULL) { - char *mesg = gettext("cancelled"); - id = papiJobGetId(*jobs); - - status = papiJobCancel(svc, - printer, id); - - if (status == PAPI_NOT_AUTHORIZED) { - mesg = papiStatusString(status); - exit_code = 1; - } else if (status != PAPI_OK) { - mesg = gettext( - verbose_papi_message( - svc, status)); - exit_code = 1; - } - /* - * If job-id-requested exists for this - * job-id then that should be displayed - */ - rid = get_job_id_requested(*jobs); - if (rid >= 0) - fprintf(OUT, "%s-%d: %s\n", - printer, rid, mesg); - else - fprintf(OUT, "%s-%d: %s\n", - printer, id, mesg); - } - papiJobListFree(jobs); - - } else { - /* Purging user's print jobs */ - exit_code = cancel_jobs_for_user(user, - encryption, printer); - } - } - papiServiceDestroy(svc); - } - - if (optind == ac) - exit_code = cancel_jobs_for_user(user, encryption, NULL); - - return (exit_code); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/common.c b/usr/src/cmd/print/bsd-sysv-commands/common.c deleted file mode 100644 index 5df4e3b9b7..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/common.c +++ /dev/null @@ -1,678 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: common.c 162 2006-05-08 14:17:44Z njacobs $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <alloca.h> -#include <string.h> -#include <libintl.h> -#include <ctype.h> -#include <pwd.h> -#include <papi.h> -#include "common.h" - -#ifndef HAVE_GETPASSPHRASE /* some systems don't have getpassphrase() */ -#define getpassphrase getpass -#endif - -/* give the most verbose error message to the caller */ -char * -verbose_papi_message(papi_service_t svc, papi_status_t status) -{ - char *mesg; - - mesg = papiServiceGetStatusMessage(svc); - - if (mesg == NULL) - mesg = papiStatusString(status); - - return (mesg); -} - -static int -match_job(int id, char *user, int ac, char *av[]) -{ - int i; - - for (i = 0; i < ac; i++) - if (strcmp("-", av[i]) == 0) - return (0); /* "current" user match */ - else if ((isdigit(av[i][0]) != 0) && (id == atoi(av[i]))) - return (0); /* job-id match */ - else if (strcmp(user, av[i]) == 0) - return (0); /* user match */ - - return (-1); -} - -/* - * return 0 : argument passed is job-id && job-id matches - * or argument passed is user - */ -static int -match_job_rid(int id, int ac, char *av[]) -{ - int i; - - for (i = 0; i < ac; i++) - if (isdigit(av[i][0]) != 0) { - if (id == atoi(av[i])) - /* job-id match */ - return (0); - } else - /* argument passed is user */ - return (0); - return (-1); -} - -static struct { - char *mime_type; - char *lp_type; -} type_map[] = { - { "text/plain", "simple" }, - { "application/octet-stream", "raw" }, - { "application/octet-stream", "any" }, - { "application/postscript", "postscript" }, - { "application/postscript", "ps" }, - { "application/x-cif", "cif" }, - { "application/x-dvi", "dvi" }, - { "application/x-plot", "plot" }, - { "application/x-ditroff", "troff" }, - { "application/x-troff", "otroff" }, - { "application/x-pr", "pr" }, - { "application/x-fortran", "fortran" }, - { "application/x-raster", "raster" }, - { NULL, NULL} -}; - -char * -lp_type_to_mime_type(char *lp_type) -{ - int i; - - if (lp_type == NULL) - return ("application/octet-stream"); - - for (i = 0; type_map[i].lp_type != NULL; i++) - if (strcasecmp(type_map[i].lp_type, lp_type) == 0) - return (type_map[i].mime_type); - - return (lp_type); -} - -/* - * to support job/printer status - */ -static char * -state_string(int state) -{ - switch (state) { - case 3: - return (gettext("idle")); - case 4: - return (gettext("processing")); - case 5: - return (gettext("stopped")); - default: - return (gettext("unknown")); - } -} - -static char *_rank_suffixes[] = { - "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" -}; - -static char * -rank_string(const int rank) -{ - static char buf[12]; - - if (rank < 0) - snprintf(buf, sizeof (buf), gettext("invalid")); - else if (rank == 0) - snprintf(buf, sizeof (buf), gettext("active")); - else if ((rank > 10) && (rank < 14)) - sprintf(buf, "%dth", rank); - else - sprintf(buf, "%d%s", rank, _rank_suffixes[rank % 10]); - - return (buf); -} - -static void -printer_state_line(FILE *fp, papi_printer_t p, int num_jobs, char *name) -{ - papi_attribute_t **list = papiPrinterGetAttributeList(p); - int state = 0; - char *reason = ""; - - (void) papiAttributeListGetInteger(list, NULL, - "printer-state", &state); - (void) papiAttributeListGetString(list, NULL, - "printer-state-reasons", &reason); - (void) papiAttributeListGetString(list, NULL, - "printer-name", &name); - - if ((state != 0x03) || (num_jobs != 0)) { - fprintf(fp, "%s: %s", name, state_string(state)); - if ((state == 0x05) || - (state == 0x06) || - (state == 0x07) || - (state == 0x08)) /* stopped */ - fprintf(fp, ": %s\n", reason); - else - fprintf(fp, "\n"); - } else - fprintf(fp, "no entries\n"); -} - -static void -print_header(FILE *fp) -{ - fprintf(fp, gettext("Rank\tOwner\t Job\tFile(s)\t\t\t\tTotal Size\n")); -} - -static void -print_job_line(FILE *fp, int count, papi_job_t job, int fmt, int ac, char *av[]) -{ - papi_attribute_t **list = papiJobGetAttributeList(job); - int copies = 1, id = 0, rank = count, size = 0; - char *name = "print job"; - char *user = "nobody"; - char *host = "localhost"; - char *suffix = "k"; - - (void) papiAttributeListGetInteger(list, NULL, - "job-id", &id); - (void) papiAttributeListGetInteger(list, NULL, - "job-id-requested", &id); - (void) papiAttributeListGetString(list, NULL, - "job-originating-user-name", &user); - (void) papiAttributeListGetString(list, NULL, - "job-originating-host-name", &host); - - /* if we are looking and it doesn't match, return early */ - if ((ac > 0) && (match_job(id, user, ac, av) < 0)) - return; - - (void) papiAttributeListGetInteger(list, NULL, - "copies", &copies); - (void) papiAttributeListGetInteger(list, NULL, - "number-of-intervening-jobs", &rank); - - if (papiAttributeListGetInteger(list, NULL, "job-octets", &size) - == PAPI_OK) - suffix = "bytes"; - else - (void) papiAttributeListGetInteger(list, NULL, - "job-k-octets", &size); - (void) papiAttributeListGetString(list, NULL, - "job-name", &name); - - size *= copies; - - if (fmt == 3) { - fprintf(fp, gettext("%s\t%-8.8s %d\t%-32.32s%d %s\n"), - rank_string(++rank), user, id, name, size, suffix); - } else - fprintf(fp, gettext( - "\n%s: %s\t\t\t\t[job %d %s]\n\t%-32.32s\t%d %s\n"), - user, rank_string(++rank), id, host, name, size, - suffix); -} - -/* - * to support job cancelation - */ -static void -cancel_job(papi_service_t svc, FILE *fp, char *printer, papi_job_t job, - int ac, char *av[]) -{ - papi_status_t status; - papi_attribute_t **list = papiJobGetAttributeList(job); - int id = -1; - int rid = -1; - char *user = ""; - char *mesg = gettext("cancelled"); - int i = 0; - - papiAttributeListGetInteger(list, NULL, - "job-id", &id); - papiAttributeListGetInteger(list, NULL, - "job-id-requested", &rid); - papiAttributeListGetString(list, NULL, - "job-originating-user-name", &user); - - /* if we are looking and it doesn't match, return early */ - if ((ac > 0) && (match_job(id, user, ac, av) < 0) && - (match_job(rid, user, ac, av) < 0)) - return; - - /* - * A remote lpd job should be cancelled only based on - * job-id-requested - */ - if (rid != -1) { - if (match_job_rid(rid, ac, av) == -1) - /* job-id mismatch */ - return; - } - - status = papiJobCancel(svc, printer, id); - if (status != PAPI_OK) - mesg = papiStatusString(status); - - if (rid != -1) - fprintf(fp, "%s-%d: %s\n", printer, rid, mesg); - else - fprintf(fp, "%s-%d: %s\n", printer, id, mesg); -} - -int -berkeley_queue_report(papi_service_t svc, FILE *fp, char *dest, int fmt, - int ac, char *av[]) -{ - papi_status_t status; - papi_printer_t p = NULL; - papi_job_t *jobs = NULL; - char *pattrs[] = { "printer-name", "printer-state", - "printer-state-reasons", NULL }; - char *jattrs[] = { "job-name", "job-octets", "job-k-octets", "job-id", - "job-originating-user-name", "job-id-requested", - "job-originating-host-name", - "number-of-intervening-jobs", NULL }; - int num_jobs = 0; - - status = papiPrinterQuery(svc, dest, pattrs, NULL, &p); - if (status != PAPI_OK) { - fprintf(fp, gettext( - "Failed to query service for state of %s: %s\n"), - dest, verbose_papi_message(svc, status)); - return (-1); - } - - status = papiPrinterListJobs(svc, dest, jattrs, PAPI_LIST_JOBS_ALL, - 0, &jobs); - if (status != PAPI_OK) { - fprintf(fp, gettext( - "Failed to query service for jobs on %s: %s\n"), - dest, verbose_papi_message(svc, status)); - return (-1); - } - if (jobs != NULL) { - while (jobs[num_jobs] != NULL) - num_jobs++; - } - - printer_state_line(fp, p, num_jobs, dest); - if (num_jobs > 0) { - int i; - - if (fmt == 3) - print_header(fp); - for (i = 0; jobs[i] != NULL; i++) - print_job_line(fp, i, jobs[i], fmt, ac, av); - } - - papiPrinterFree(p); - papiJobListFree(jobs); - - return (num_jobs); -} - -int -berkeley_cancel_request(papi_service_t svc, FILE *fp, char *dest, - int ac, char *av[]) -{ - papi_status_t status; - papi_job_t *jobs = NULL; - char *jattrs[] = { "job-originating-user-name", "job-id", - "job-id-requested", NULL }; - - status = papiPrinterListJobs(svc, dest, jattrs, PAPI_LIST_JOBS_ALL, - 0, &jobs); - - if (status != PAPI_OK) { - fprintf(fp, gettext("Failed to query service for %s: %s\n"), - dest, verbose_papi_message(svc, status)); - return (-1); - } - - /* cancel the job(s) */ - if (jobs != NULL) { - int i; - - for (i = 0; jobs[i] != NULL; i++) - cancel_job(svc, fp, dest, jobs[i], ac, av); - } - - papiJobListFree(jobs); - - return (0); -} - -int -get_printer_id(char *name, char **printer, int *id) -{ - int result = -1; - - if (name != NULL) { - char *p = strrchr(name, '-'); - - *printer = name; - if (p != NULL) { - char *s = NULL; - - *id = strtol(p + 1, &s, 10); - if (s[0] != '\0') - *id = -1; - else - *p = '\0'; - result = 0; - } else - *id = -1; - } - - return (result); -} - -/* - * strsplit() splits a string into a NULL terminated array of substrings - * determined by a seperator. The original string is modified, and newly - * allocated space is only returned for the array itself. If more than - * 1024 substrings exist, they will be ignored. - */ -char ** -strsplit(char *string, const char *seperators) -{ - char *list[BUFSIZ], - **result; - int length = 0; - - if ((string == NULL) || (seperators == NULL)) - return (NULL); - - (void) memset(list, 0, sizeof (list)); - for (list[length] = strtok(string, seperators); - (list[length] != NULL) && (length < (BUFSIZ - 2)); - list[length] = strtok(NULL, seperators)) - length++; - - if ((result = (char **)calloc(length+1, sizeof (char *))) != NULL) - (void) memcpy(result, list, length * sizeof (char *)); - - return (result); -} - -papi_status_t -jobSubmitSTDIN(papi_service_t svc, char *printer, char *prefetch, int len, - papi_attribute_t **list, papi_job_t *job) -{ - papi_status_t status; - papi_stream_t stream = NULL; - int rc; - char buf[BUFSIZ]; - - status = papiJobStreamOpen(svc, printer, list, NULL, &stream); - - if (len > 0) - status = papiJobStreamWrite(svc, stream, prefetch, len); - - while ((status == PAPI_OK) && ((rc = read(0, buf, sizeof (buf))) > 0)) - status = papiJobStreamWrite(svc, stream, buf, rc); - - if (status == PAPI_OK) - status = papiJobStreamClose(svc, stream, job); - - return (status); -} - -/* - * is_postscript() will detect if the file passed in contains postscript - * data. A one is returned if the file contains postscript, zero is returned - * if the file is not postscript, and -1 is returned if an error occurs - */ -#define PS_MAGIC "%!" -#define PC_PS_MAGIC "^D%!" -int -is_postscript_stream(int fd, char *buf, int *len) -{ - if ((*len = read(fd, buf, *len)) < 0) { - close(fd); - return (-1); - } - - if ((strncmp(buf, PS_MAGIC, sizeof (PS_MAGIC) - 1) == 0) || - (strncmp(buf, PC_PS_MAGIC, sizeof (PC_PS_MAGIC) - 1) == 0)) - return (1); - else - return (0); -} - -int -is_postscript(const char *file) -{ - int rc = -1; - int fd; - - if ((fd = open(file, O_RDONLY)) >= 0) { - char buf[3]; - int len = sizeof (buf); - - rc = is_postscript_stream(fd, buf, &len); - close(fd); - } - - return (rc); -} - -static char ** -all_list(papi_service_t svc) -{ - papi_status_t status; - papi_printer_t printer = NULL; - char *list[] = { "member-names", NULL }; - char **result = NULL; - - status = papiPrinterQuery(svc, "_all", list, NULL, &printer); - if ((status == PAPI_OK) && (printer != NULL)) { - papi_attribute_t **attributes = - papiPrinterGetAttributeList(printer); - if (attributes != NULL) { - void *iter = NULL; - char *value = NULL; - - for (status = papiAttributeListGetString(attributes, - &iter, "member-names", &value); - status == PAPI_OK; - status = papiAttributeListGetString(attributes, - &iter, NULL, &value)) - list_append(&result, strdup(value)); - } - papiPrinterFree(printer); - } - - return (result); -} - -static char ** -printers_list(papi_service_t svc) -{ - papi_status_t status; - papi_printer_t *printers = NULL; - char *keys[] = { "printer-name", NULL }; - char **result = NULL; - - status = papiPrintersList(svc, keys, NULL, &printers); - if ((status == PAPI_OK) && (printers != NULL)) { - int i; - - for (i = 0; printers[i] != NULL; i++) { - papi_attribute_t **attributes = - papiPrinterGetAttributeList(printers[i]); - char *name = NULL; - - (void) papiAttributeListGetString(attributes, NULL, - "printer-name", &name); - if ((name != NULL) && (strcmp(name, "_default") != 0)) - list_append(&result, strdup(name)); - } - papiPrinterListFree(printers); - } - - return (result); -} - -char ** -interest_list(papi_service_t svc) -{ - static char been_here; - static char **result; - - if (been_here == 0) { /* only do this once */ - been_here = 1; - - if ((result = all_list(svc)) == NULL) - result = printers_list(svc); - } - - return (result); -} - -char * -localhostname() -{ - static char *result; - - if (result == NULL) { - static char buf[256]; - - if (gethostname(buf, sizeof (buf)) == 0) - result = buf; - } - - return (result); -} - -int -cli_auth_callback(papi_service_t svc, void *app_data) -{ - char prompt[BUFSIZ]; - char *user, *svc_name, *passphrase; - - /* get the name of the service we are contacting */ - if ((svc_name = papiServiceGetServiceName(svc)) == NULL) - return (-1); - - /* find our who we are supposed to be */ - if ((user = papiServiceGetUserName(svc)) == NULL) { - struct passwd *pw; - - if ((pw = getpwuid(getuid())) != NULL) - user = pw->pw_name; - else - user = "nobody"; - } - - /* build the prompt string */ - snprintf(prompt, sizeof (prompt), - gettext("passphrase for %s to access %s: "), user, svc_name); - - /* ask for the passphrase */ - if ((passphrase = getpassphrase(prompt)) != NULL) - papiServiceSetPassword(svc, passphrase); - - return (0); -} - -int32_t -job_to_be_queried(papi_service_t svc, char *printer, int32_t id) -{ - papi_job_t *jobs = NULL; - papi_status_t status; - int ret = -1; - char *jattrs[] = { "job-id", - "job-id-requested", NULL }; - - status = papiPrinterListJobs(svc, printer, jattrs, PAPI_LIST_JOBS_ALL, - 0, &jobs); - - if (status != PAPI_OK) { - fprintf(stderr, gettext("Failed to query service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - return (-1); - } - - if (jobs != NULL) { - int i = 0; - - for (i = 0; jobs[i] != NULL; i++) { - int32_t rid = -1; - int32_t jid = -1; - papi_attribute_t **list = - papiJobGetAttributeList(jobs[i]); - - papiAttributeListGetInteger(list, NULL, - "job-id-requested", &rid); - papiAttributeListGetInteger(list, NULL, - "job-id", &jid); - - /* - * check if id matches with either rid or jid - */ - if (rid == id) { - /* get the actual id and return it */ - papiAttributeListGetInteger(list, NULL, - "job-id", &id); - return (id); - } else if (id == jid) { - if (rid != -1) { - /* - * It is a remote lpd job - * can be cancelled only - * using rid - */ - ret = -1; - } else { - /* - * its local or - * remote ipp job - */ - return (id); - } - } - } - return (ret); - } - return (id); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/common.h b/usr/src/cmd/print/bsd-sysv-commands/common.h deleted file mode 100644 index a729930bd5..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/common.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -#ifndef _BSD_SYSV_COMMON_H -#define _BSD_SYSV_COMMON_H - -/* $Id: common.h 162 2006-05-08 14:17:44Z njacobs $ */ - -#include <papi.h> - -#include <config-site.h> - -#ifdef __cplusplus -extern "C" { -#endif - -extern char **strsplit(char *string, const char *seperators); -extern char *verbose_papi_message(papi_service_t svc, papi_status_t status); - -extern int berkeley_cancel_request(papi_service_t svc, FILE *fp, char *dest, - int ac, char *av[]); - -extern int get_printer_id(char *name, char **printer, int *id); - -extern int berkeley_queue_report(papi_service_t svc, FILE *fp, char *dest, - int fmt, int ac, char *av[]); - -extern papi_status_t jobSubmitSTDIN(papi_service_t svc, char *printer, - char *prefetch, int len, - papi_attribute_t **list, papi_job_t *job); - -extern char **interest_list(papi_service_t svc); -extern char *localhostname(); -extern char *lp_type_to_mime_type(char *lp_type); -extern int is_postscript(const char *file); -extern int is_postscript_stream(int fd, char *buf, int *len); - -extern int cli_auth_callback(papi_service_t svc, void *app_data); - -extern int32_t job_to_be_queried(papi_service_t svc, char *printer, int32_t id); - -#ifdef __cplusplus -} -#endif - -#endif /* _BSD_SYSV_COMMON_H */ diff --git a/usr/src/cmd/print/bsd-sysv-commands/disable.c b/usr/src/cmd/print/bsd-sysv-commands/disable.c deleted file mode 100644 index 0b3cb71f0c..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/disable.c +++ /dev/null @@ -1,163 +0,0 @@ - -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: disable.c 146 2006-03-24 00:26:54Z njacobs $ */ - - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s [-c] [-W] [-r reason] destination ...\n"), - name); - exit(1); -} - -static void -cancel_active_job(papi_service_t svc, char *dest) -{ - papi_status_t status; - papi_job_t *j = NULL; - char *req_attrs[] = { "job-state", "job-id", NULL }; - - status = papiPrinterListJobs(svc, dest, req_attrs, 0, 0, &j); - if ((status == PAPI_OK) && (j != NULL)) { - int i; - - for (i = 0; j[i] != NULL; j++) { - papi_attribute_t **a = papiJobGetAttributeList(j[i]); - int state = 0; - - if (a == NULL) - continue; - - (void) papiAttributeListGetInteger(a, NULL, - "job-state", &state); - if (state & 0x082A) { /* If state is RS_ACTIVE */ - int32_t id = papiJobGetId(j[i]); - - (void) papiJobCancel(svc, dest, id); - } - } - papiJobListFree(j); - } -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int exit_status = 0; - int cancel = 0; - int pending = 0; /* not implemented */ - char *reason = NULL; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "EcWr:")) != EOF) - switch (c) { - case 'c': /* cancel active job first */ - cancel = 1; - break; - case 'W': /* wait for active request, not implemented */ - pending = 1; - break; - case 'r': /* reason */ - reason = optarg; - break; - case 'E': - encryption = PAPI_ENCRYPT_NEVER; - break; - default: - usage(av[0]); - } - - if (ac <= optind) - usage(av[0]); - - while (optind < ac) { - char *printer = av[optind++]; - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit_status = 1; - } - - status = papiPrinterDisable(svc, printer, reason); - if (status == PAPI_OK) { - printf(gettext("printer \"%s\" now disabled\n"), - printer); - } else if (status == PAPI_NOT_ACCEPTING) { - fprintf(stderr, gettext( - "Destination \"%s\" was already disabled.\n"), - printer); - exit_status = 1; - } else { - /* The operation is not supported in lpd protocol */ - if (status == PAPI_OPERATION_NOT_SUPPORTED) { - fprintf(stderr, - verbose_papi_message(svc, status)); - } else { - fprintf(stderr, gettext("disable: %s: %s\n"), - printer, verbose_papi_message(svc, status)); - } - exit_status = 1; - } - - if (cancel != 0) - cancel_active_job(svc, printer); - - papiServiceDestroy(svc); - } - - return (exit_status); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/enable.c b/usr/src/cmd/print/bsd-sysv-commands/enable.c deleted file mode 100644 index c197337e1e..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/enable.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: enable.c 146 2006-03-24 00:26:54Z njacobs $ */ - - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s destination ...\n"), - name); - exit(1); -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int exit_status = 0; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "E")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_ALWAYS; - break; - default: - usage(av[0]); - } - - if (ac == optind) - usage(av[0]); - - for (c = optind; c < ac; c++) { - char *printer = av[c]; - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit_status = 1; - } - - status = papiPrinterEnable(svc, printer); - if (status == PAPI_OK) { - printf(gettext("printer \"%s\" now enabled\n"), - printer); - } else if (status == PAPI_NOT_ACCEPTING) { - fprintf(stderr, gettext( - "Destination \"%s\" was already enabled.\n"), - printer); - exit_status = 1; - } else { - /* The operation is not supported in lpd protocol */ - if (status == PAPI_OPERATION_NOT_SUPPORTED) { - fprintf(stderr, - verbose_papi_message(svc, status)); - } else { - fprintf(stderr, gettext("enable: %s: %s\n"), - printer, verbose_papi_message(svc, status)); - } - exit_status = 1; - } - - papiServiceDestroy(svc); - } - - return (exit_status); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c b/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c deleted file mode 100644 index 1b058ac291..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c +++ /dev/null @@ -1,786 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: in.lpd.c 170 2006-05-20 05:58:49Z njacobs $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdarg.h> -#include <string.h> -#include <ctype.h> -#include <errno.h> -#include <syslog.h> -#include <libintl.h> -#include <pwd.h> -#include <grp.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <sys/systeminfo.h> - -#include <papi.h> -#include <uri.h> -#include "common.h" - -#define ACK(fp) { (void) fputc('\0', fp); (void) fflush(fp); } -#define NACK(fp) { (void) fputc('\1', fp); (void) fflush(fp); } - -/* - * This file contains the front-end of the BSD Print Protocol adaptor. This - * code assumes a BSD Socket interface to the networking side. - */ - -static char * -remote_host_name(FILE *fp) -{ - struct hostent *hp; - struct sockaddr_in6 peer; - socklen_t peer_len = sizeof (peer); - int fd = fileno(fp); - int error_num; - char tmp_buf[INET6_ADDRSTRLEN]; - char *hostname; - - /* who is our peer ? */ - if (getpeername(fd, (struct sockaddr *)&peer, &peer_len) < 0) { - if ((errno != ENOTSOCK) && (errno != EINVAL)) - return (NULL); - else - return (strdup("localhost")); - } - - /* get their name or return a string containing their address */ - if ((hp = getipnodebyaddr((const char *)&peer.sin6_addr, - sizeof (struct in6_addr), AF_INET6, - &error_num)) == NULL) { - return (strdup(inet_ntop(peer.sin6_family, - &peer.sin6_addr, tmp_buf, sizeof (tmp_buf)))); - } - - hostname = strdup(hp->h_name); - if (is_localhost(hp->h_name) != 0) - return (strdup("localhost")); - - /* It must be someone else */ - return (hostname); -} - -static void -fatal(FILE *fp, char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsyslog(LOG_DEBUG, fmt, ap); - vfprintf(fp, fmt, ap); - va_end(ap); - exit(1); -} - -static void -cleanup(char ***files, char **cf) -{ - if (*files != NULL) { - int i; - - for (i = 0; (*files)[i] != NULL; i++) { - (void) unlink((*files)[i]); - free((*files)[i]); - } - free(*files); - *files = NULL; - } - - if (*cf != NULL) { - free(*cf); - *cf = NULL; - } -} - -static papi_attribute_t ** -parse_cf(papi_service_t svc, char *cf, char **files) -{ - papi_attribute_t **list = NULL; - char previous = NULL; - char *entry; - int copies_set = 0; - int copies = 0; - - for (entry = strtok(cf, "\n"); entry != NULL; - entry = strtok(NULL, "\n")) { - char *format = NULL; - - /* count the copies */ - if ((entry[0] >= 'a') && (entry[0] <= 'z') && - (copies_set == 0) && (previous == entry[0])) - copies++; - else if ((previous >= 'a') && (previous <= 'z')) - copies_set = 1; - previous = entry[0]; - - /* process the control message */ - switch (entry[0]) { - /* RFC-1179 options */ - case 'J': /* RFC-1179 Banner Job Name */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-name", ++entry); - break; - case 'C': /* RFC-1179 Banner Class Name */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-class", ++entry); - break; - case 'L': /* RFC-1179 Banner toggle */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-sheets", "standard"); - break; - case 'T': /* RFC-1179 Title (pr) */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "pr-title", ++entry); - break; - case 'H': /* RFC-1179 Host */ - /* - * use the host as known by us, not by them - * - * papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - * "job-originating-host-name", ++entry); - */ - break; - case 'P': /* RFC-1179 User */ - ++entry; - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-originating-user-name", entry); - papiServiceSetUserName(svc, entry); - break; - case 'M': /* RFC-1179 Mail to User */ - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "rfc-1179-mail", 1); - break; - case 'W': /* RFC-1179 Width (pr) */ - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "pr-width", atoi(++entry)); - break; - case 'I': /* RFC-1179 Indent (pr) */ - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "pr-indent", atoi(++entry)); - break; - case 'N': /* RFC-1179 Filename */ - /* could have HPUX extension embedded */ - if (entry[1] != ' ') { /* real pathname */ -#ifdef DEBUG - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "flist", ++entry); -#endif - } else if (entry[2] == 'O') /* HPUX lp -o options */ - papiAttributeListFromString(&list, - PAPI_ATTR_APPEND, ++entry); - break; - case 'U': /* RFC-1179 Unlink */ - break; /* ignored */ - case '1': /* RFC-1179 TROFF Font R */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-r", ++entry); - break; - case '2': /* RFC-1179 TROFF Font I */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-i", ++entry); - break; - case '3': /* RFC-1179 TROFF Font B */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-b", ++entry); - break; - case '4': /* RFC-1179 TROFF Font S */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-s", ++entry); - break; - case 'f': /* RFC-1179 ASCII file (print) */ - format = "text/plain"; - if (is_postscript(files[0]) == 1) - format = "application/postscript"; - break; - case 'l': /* RFC-1179 CATV file (print) */ - format = "application/octet-stream"; - if (is_postscript(files[0]) == 1) - format = "application/postscript"; - break; - case 'o': /* RFC-1179 Postscript file (print) */ - format = "application/postscript"; - break; - case 'p': /* RFC-1179 PR file (print) */ - format = "application/x-pr"; - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "pr-filter", 1); - break; - case 't': /* RFC-1179 TROFF file (print) */ - format = "application/x-troff"; - break; - case 'n': /* RFC-1179 DITROFF file (print) */ - format = "application/x-ditroff"; - break; - case 'd': /* RFC-1179 DVI file (print) */ - format = "application/x-dvi"; - break; - case 'g': /* RFC-1179 GRAPH file (print) */ - format = "application/x-plot"; - break; - case 'c': /* RFC-1179 CIF file (print) */ - format = "application/x-cif"; - break; - case 'v': /* RFC-1179 RASTER file (print) */ - format = "application/x-raster"; - break; - case 'r': /* RFC-1179 FORTRAN file (print) */ - format = "application/x-fortran"; - break; - /* Sun Solaris Extensions */ - case 'O': - ++entry; - { - int rd, wr; - - for (rd = wr = 0; entry[rd] != '\0'; rd++) { - if (entry[rd] == '"') - continue; - if (rd != wr) - entry[wr] = entry[rd]; - wr++; - } - entry[wr] = '\0'; - - papiAttributeListFromString(&list, - PAPI_ATTR_APPEND, entry); - } - break; - case '5': - ++entry; - switch (entry[0]) { - case 'f': /* Solaris form */ - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "form", ++entry); - break; - case 'H': /* Solaris handling */ - ++entry; - if (strcasecmp(entry, "hold") == 0) - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "job-hold-until", "indefinite"); - else if (strcasecmp(entry, "immediate") == 0) - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "job-hold-until", "no-hold"); - else - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "job-hold-until", entry); - break; - case 'p': /* Solaris notification */ - papiAttributeListAddBoolean(&list, - PAPI_ATTR_EXCL, "rfc-1179-mail", 1); - break; - case 'P': { /* Solaris page list */ - char buf[BUFSIZ]; - - snprintf(buf, sizeof (buf), "page-ranges=%s", - ++entry); - papiAttributeListFromString(&list, - PAPI_ATTR_EXCL, buf); - } - break; - case 'q': { /* Solaris priority */ - int i = atoi(++entry); - - i = 100 - (i * 2.5); - if ((i < 1) || (i > 100)) - i = 50; - papiAttributeListAddInteger(&list, - PAPI_ATTR_EXCL, "job-priority", i); - } - break; - case 'S': /* Solaris character set */ - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, "lp-charset", - ++entry); - break; - case 'T': /* Solaris type */ - format = lp_type_to_mime_type(++entry); - break; - case 'y': /* Solaris mode */ - papiAttributeListAddString(&list, - PAPI_ATTR_APPEND, "lp-modes", ++entry); - break; - default: - syslog(LOG_INFO|LOG_DEBUG, - "Warning: cf message (%s) ignored", - entry); - break; - } - break; - /* Undefined Extensions: SCO, Ultrix, AIX, ... */ - - default: - syslog(LOG_INFO|LOG_DEBUG, - "Warning: cf message (%s) ignored", entry); - break; - } - - if (format != NULL) - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", format); - } - - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "copies", ++copies); - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-sheets", "none"); - - return (list); -} - -static papi_status_t -submit_job(papi_service_t svc, FILE *ifp, char *printer, int rid, char *cf, - char **files) -{ - papi_attribute_t **list = NULL; - papi_status_t status; - papi_job_t job = NULL; - char *format = ""; - - if ((list = parse_cf(svc, cf, files)) != NULL) { - /* use the host as known by us, not by them */ - char *host = remote_host_name(ifp); - - if (host != NULL) { - papiAttributeListAddString(&list, PAPI_ATTR_REPLACE, - "job-originating-host-name", host); - free(host); - } - if (rid >= 0) { - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "job-id-requested", rid); - } - } - - status = papiJobSubmit(svc, printer, list, NULL, files, &job); - syslog(LOG_DEBUG, "submit: %s", papiStatusString(status)); - if (status != PAPI_OK) { - char *tmp = papiServiceGetStatusMessage(svc); - - syslog(LOG_DEBUG, "submit-detail: %s", tmp ? tmp : "none"); - } - papiJobFree(job); - - return (status); -} - -static char * -receive_control_file(papi_service_t svc, FILE *ifp, FILE *ofp, int size) -{ - char *ptr, *cf_data; - - if ((ptr = cf_data = calloc(1, size + 1)) == NULL) { - NACK(ofp); - return (NULL); - } else - ACK(ofp); - - while (size > 0) { - int rc; - - if (((rc = fread(ptr, 1, size, ifp)) == 0) && - (feof(ifp) != 0)) { - free(cf_data); - return (NULL); - } else { - ptr += rc; - size -= rc; - } - } - syslog(LOG_DEBUG, "cf_data(%s)", cf_data); - - if (fgetc(ifp) != 0) { - free(cf_data); - return (NULL); - } - ACK(ofp); - - return (cf_data); -} - -static char * -receive_data_file(FILE *ifp, FILE *ofp, int size) -{ - char file[] = "lpdXXXXXX"; - char buf[BUFSIZ]; - int fd; - - if ((fd = mkstemp(file)) < 0) { - NACK(ofp); - return (NULL); - } else - ACK(ofp); - - while (size > 0) { - int rc = ((size > BUFSIZ) ? BUFSIZ : size); - - if (((rc = fread(buf, 1, rc, ifp)) == 0) && - (feof(ifp) != 0)) { - close(fd); - unlink(file); - return (NULL); - } else { - char *ptr = buf; - - while (rc > 0) { - int wrc = write(fd, ptr, rc); - - if (wrc < 0) { - close(fd); - unlink(file); - return (NULL); - } - - ptr += wrc; - size -= wrc; - rc -= wrc; - } - } - } - close(fd); - if (fgetc(ifp) != 0) { - unlink(file); - return (NULL); - } - ACK(ofp); - - return (strdup(file)); -} - -static papi_status_t -berkeley_receive_files(papi_service_t svc, FILE *ifp, FILE *ofp, char *printer) -{ - papi_status_t status = PAPI_OK; - char *file, **files = NULL; /* the job data files */ - char *cf = NULL; - int rid = 0; - char buf[BUFSIZ]; - - while (fgets(buf, sizeof (buf), ifp) != NULL) { - int size; - - syslog(LOG_DEBUG, "XFER CMD: (%d)%s\n", buf[0], &buf[1]); -#ifdef DEBUG /* translate [1-3]... messages to \[1-3] to run by hand */ - if ((buf[0] > '0') && (buf[0] < '4')) - buf[0] -= '0'; -#endif - switch (buf[0]) { - case 0x01: /* Abort */ - cleanup(&files, &cf); - break; - case 0x02: { /* Receive control file */ - if (((cf = strchr(buf, ' ')) != NULL) && - (strlen(cf) > 4)) { - while ((*cf != NULL) && (isdigit(*cf) == 0)) - cf++; - rid = atoi(cf); - } - cf = receive_control_file(svc, ifp, ofp, atoi(&buf[1])); - if (cf == NULL) { - cleanup(&files, &cf); - return (PAPI_BAD_REQUEST); - } else if (files != NULL) { - status = submit_job(svc, ifp, printer, rid, cf, - files); - cleanup(&files, &cf); - } - } - break; - case 0x03: { /* Receive data file */ - file = receive_data_file(ifp, ofp, atoi(&buf[1])); - if (file == NULL) { - cleanup(&files, &cf); - return (PAPI_TEMPORARY_ERROR); - } - list_append(&files, file); - } - break; - default: - cleanup(&files, &cf); - fatal(ofp, "protocol screwup"); - break; - } - } - - if ((cf != NULL) && (files != NULL)) - status = submit_job(svc, ifp, printer, rid, cf, files); - - cleanup(&files, &cf); - - return (status); -} - -static papi_status_t -berkeley_transfer_files(papi_service_t svc, FILE *ifp, FILE *ofp, - char *printer) -{ - papi_status_t status; - papi_printer_t p = NULL; - char *keys[] = { "printer-is-accepting-jobs", NULL }; - - status = papiPrinterQuery(svc, printer, keys, NULL, &p); - if ((status == PAPI_OK) && (p != NULL)) { - papi_attribute_t **attrs = papiPrinterGetAttributeList(p); - char accepting = PAPI_FALSE; - - papiAttributeListGetBoolean(attrs, NULL, - "printer-is-accepting-jobs", &accepting); - - if (accepting == PAPI_TRUE) { - ACK(ofp); - status = berkeley_receive_files(svc, ifp, ofp, printer); - } else - NACK(ofp); - - papiPrinterFree(p); - } else - NACK(ofp); - - return (status); -} - -static int -cyclical_service_check(char *svc_name) -{ - papi_attribute_t **list; - uri_t *uri = NULL; - char *s = NULL; - - /* was there a printer? */ - if (svc_name == NULL) - return (0); - - if ((list = getprinterbyname(svc_name, NULL)) == NULL) - return (0); /* if it doesnt' resolve, we will fail later */ - - papiAttributeListGetString(list, NULL, "printer-uri-supported", &s); - if ((s == NULL) || (strcasecmp(svc_name, s) != 0)) - return (0); /* they don't match */ - - /* is it in uri form? */ - if (uri_from_string(s, &uri) < 0) - return (0); - - if ((uri == NULL) || (uri->scheme == NULL) || (uri->host == NULL)) { - uri_free(uri); - return (0); - } - - /* is it in lpd form? */ - if (strcasecmp(uri->scheme, "lpd") != 0) { - uri_free(uri); - return (0); - } - - /* is it the local host? */ - if (is_localhost(uri->host) != 0) { - uri_free(uri); - return (0); - } - - uri_free(uri); - return (1); -} - - -/* - * This is the entry point for this program. The program takes the - * following options: - * (none) - */ -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - FILE *ifp = stdin; - FILE *ofp = stdout; - int c; - char buf[BUFSIZ]; - char **args; - char *printer; - char *run_dir = "/var/run/in.lpd"; - char *run_user = NULL; - struct passwd *pw = NULL; - - (void) chdir("/tmp"); /* run in /tmp by default */ - openlog("bsd-gw", LOG_PID, LOG_LPR); - - while ((c = getopt(ac, av, "Ed:u:")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_ALWAYS; - break; - case 'd': /* run where they tell you */ - run_dir = optarg; - break; - case 'u': /* run as */ - run_user = optarg; - break; - default: - ; - } - - if (run_user != NULL) /* get the requested user info */ - pw = getpwnam(run_user); - - if (run_dir != NULL) { /* setup the run_dir */ - (void) mkdir(run_dir, 0700); - if (pw != NULL) - (void) chown(run_dir, pw->pw_uid, pw->pw_gid); - } - - if (pw != NULL) { /* run as the requested user */ - syslog(LOG_DEBUG, "name: %s, uid: %d, gid: %d", - pw->pw_name, pw->pw_uid, pw->pw_gid); - initgroups(pw->pw_name, pw->pw_gid); - setgid(pw->pw_gid); - setuid(pw->pw_uid); - } - - if (run_dir != NULL) /* move to the run_dir */ - if (chdir(run_dir) < 0) { - syslog(LOG_DEBUG, "failed to chdir(%s)", run_dir); - exit(1); - } - - syslog(LOG_DEBUG, "$CWD = %s", getwd(NULL)); - - if (fgets(buf, sizeof (buf), ifp) == NULL) { - if (feof(ifp) == 0) - syslog(LOG_ERR, "Error reading from connection: %s", - strerror(errno)); - exit(1); - } - - syslog(LOG_DEBUG, "CMD: (%d)%s\n", buf[0], &buf[1]); - -#ifdef DEBUG /* translate [1-5]... messages to \[1-5] to run by hand */ - if ((buf[0] > '0') && (buf[0] < '6')) - buf[0] -= '0'; -#endif - - if ((buf[0] < 1) || (buf[0] > 5)) { - fatal(ofp, "Invalid protocol request (%d): %c%s\n", - buf[0], buf[0], buf); - exit(1); - } - - args = strsplit(&buf[1], "\t\n "); - printer = *args++; - - if (printer == NULL) { - fatal(ofp, "Can't determine requested printer"); - exit(1); - } - - if (cyclical_service_check(printer) != 0) { - fatal(ofp, "%s is cyclical\n", printer); - exit(1); - } - - status = papiServiceCreate(&svc, printer, NULL, NULL, NULL, - encryption, NULL); - if (status != PAPI_OK) { - fatal(ofp, "Failed to contact service for %s: %s\n", printer, - verbose_papi_message(svc, status)); - exit(1); - } - - /* - * Trusted Solaris can't be trusting of intermediaries. Pass - * the socket connection to the print service to retrieve the - * sensativity label off of a multi-level port. - */ - (void) papiServiceSetPeer(svc, fileno(ifp)); - - switch (buf[0]) { - case '\1': /* restart printer */ - ACK(ofp); /* there is no equivalent */ - break; - case '\2': /* transfer job(s) */ - status = berkeley_transfer_files(svc, ifp, ofp, printer); - break; - case '\3': /* show queue (short) */ - case '\4': { /* show queue (long) */ - int count; - - for (count = 0; args[count] != 0; count++) {} - - berkeley_queue_report(svc, ofp, printer, buf[0], count, args); - } - break; - case '\5': { /* cancel job(s) */ - char *user = *args++; - char *host = remote_host_name(ifp); - int count; - - if (host != NULL) { - char buf[BUFSIZ]; - - snprintf(buf, sizeof (buf), "%s@%s", user, host); - status = papiServiceSetUserName(svc, buf); - } else - status = papiServiceSetUserName(svc, user); - - for (count = 0; args[count] != 0; count++) {} - - berkeley_cancel_request(svc, ofp, printer, count, args); - } - break; - default: - fatal(ofp, "unsupported protocol request (%c), %s", - buf[0], &buf[1]); - } - - (void) fflush(ofp); - - syslog(LOG_DEBUG, "protocol request(%d) for %s completed: %s", - buf[0], printer, papiStatusString(status)); - if (status != PAPI_OK) - syslog(LOG_DEBUG, "detail: %s", - verbose_papi_message(svc, status)); - - papiServiceDestroy(svc); - - return (0); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lp.c b/usr/src/cmd/print/bsd-sysv-commands/lp.c deleted file mode 100644 index 9ec5d0fed2..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lp.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - * - */ - -/* $Id: lp.c 179 2006-07-17 18:24:07Z njacobs $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" -#include <pwd.h> -#include <grp.h> -#include <sys/types.h> -#ifdef HAVE_LIBMAGIC /* for mimetype auto-detection */ -#include <magic.h> -#endif /* HAVE_LIBMAGIC */ - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s [-c] [-m] [-p] [-s] [-w] [-d destination] " - "[-f form-name] [-H special-handling] [-n number] " - "[-o option] [-P page-list] [-q priority-level] " - "[-S character-set | print-wheel] [-t title] [-v] " - "[-T content-type [-r]] [-y mode-list] [file...]\n"), - name); - exit(1); -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_attribute_t **list = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - papi_job_t job = NULL; - char prefetch[3]; - int prefetch_len = sizeof (prefetch); - char *printer = NULL; - char b = PAPI_TRUE; - int copy = 0; - int silent = 0; - int dump = 0; - int validate = 0; - int modify = -1; - int c; - uid_t ruid; - struct passwd *pw; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - ruid = getuid(); - if ((pw = getpwuid(ruid)) != NULL) - (void) initgroups(pw->pw_name, pw->pw_gid); - (void) setuid(ruid); - - - while ((c = getopt(ac, av, "DEH:P:S:T:cd:f:i:mn:o:pq:rst:Vwy:")) != EOF) - switch (c) { - case 'H': /* handling */ - if (strcasecmp(optarg, "hold") == 0) - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "job-hold-until", "indefinite"); - else if (strcasecmp(optarg, "immediate") == 0) - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "job-hold-until", "no-hold"); - else - papiAttributeListAddString(&list, - PAPI_ATTR_EXCL, - "job-hold-until", optarg); - break; - case 'P': { /* page list */ - char buf[BUFSIZ]; - - snprintf(buf, sizeof (buf), "page-ranges=%s", optarg); - papiAttributeListFromString(&list, - PAPI_ATTR_EXCL, buf); - } - break; - case 'S': /* charset */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "lp-charset", optarg); - break; - case 'T': /* type */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", - lp_type_to_mime_type(optarg)); - break; - case 'D': /* dump */ - dump = 1; - break; - case 'c': /* copy */ - copy = 1; - break; - case 'd': /* destination */ - printer = optarg; - break; - case 'f': /* form */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "form", optarg); - break; - case 'i': /* modify job */ - if ((get_printer_id(optarg, &printer, &modify) < 0) || - (modify < 0)) { - fprintf(stderr, - gettext("invalid request id: %s\n"), - optarg); - exit(1); - } - break; - case 'm': /* mail when complete */ - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "rfc-1179-mail", 1); - break; - case 'n': /* copies */ - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "copies", atoi(optarg)); - break; - case 'o': /* lp "options" */ - papiAttributeListFromString(&list, - PAPI_ATTR_REPLACE, optarg); - break; - case 'p': /* Solaris - notification */ - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "rfc-1179-mail", 1); - break; - case 'q': { /* priority */ - int i = atoi(optarg); - - i = 100 - (i * 2.5); - if ((i < 1) || (i > 100)) { - fprintf(stderr, gettext("UX:lp: ")); - fprintf(stderr, gettext("ERROR: ")); - fprintf(stderr, gettext("Bad priority" - " value \"%s\"."), optarg); - fprintf(stderr, gettext("\n ")); - fprintf(stderr, gettext("TO FIX")); - fprintf(stderr, gettext(": ")); - fprintf(stderr, gettext("Use an integer value" - " from 0 to 39.")); - fprintf(stderr, gettext("\n")); - exit(1); - } - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "job-priority", i); - } - break; - case 'r': /* "raw" mode */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", - "application/octet-stream"); - papiAttributeListAddString(&list, PAPI_ATTR_APPEND, - "stty", "raw"); - break; - case 's': /* suppress message */ - silent = 1; - break; - case 't': /* title */ - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-name", optarg); - break; - case 'V': /* validate */ - validate = 1; - break; - case 'w': - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "rfc-1179-mail", 1); - break; - case 'y': /* lp "modes" */ - papiAttributeListAddString(&list, PAPI_ATTR_APPEND, - "lp-modes", optarg); - break; - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - default: - usage(av[0]); - } - - /* convert "banner", "nobanner" to "job-sheet" */ - if (papiAttributeListGetBoolean(list, NULL, "banner", &b) == PAPI_OK) { - (void) papiAttributeListDelete(&list, "banner"); - if (b == PAPI_FALSE) - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-sheets", "none"); - } - - if ((printer == NULL) && - ((printer = getenv("PRINTER")) == NULL) && - ((printer = getenv("LPDEST")) == NULL)) - printer = DEFAULT_DEST; - - if (((optind + 1) == ac) && (strcmp(av[optind], "-") == 0)) - optind = ac; - - if (modify == -1) { - char *document_format = "text/plain"; - - if (optind != ac) { - /* get the mime type of the file data */ -#ifdef MAGIC_MIME - magic_t ms = NULL; - - if ((ms = magic_open(MAGIC_MIME)) != NULL) { - document_format = magic_file(ms, av[optind]); - magic_close(ms); - } -#else - if (is_postscript(av[optind]) == 1) - document_format = "application/postscript"; -#endif - } else { - if (is_postscript_stream(0, prefetch, &prefetch_len) - == 1) - document_format = "application/postscript"; - } - - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1); - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", document_format); - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-sheets", "standard"); - } - - status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), printer, - verbose_papi_message(svc, status)); - exit(1); - } - - if (dump != 0) { - printf("requesting attributes:\n"); - papiAttributeListPrint(stdout, list, "\t"); - printf("\n"); - } - - if (modify != -1) - status = papiJobModify(svc, printer, modify, list, &job); - else if (optind == ac) /* no file list, use stdin */ - status = jobSubmitSTDIN(svc, printer, prefetch, prefetch_len, - list, &job); - else if (validate == 1) /* validate the request can be processed */ - status = papiJobValidate(svc, printer, list, - NULL, &av[optind], &job); - else if (copy == 0) /* reference the files in the job, default */ - status = papiJobSubmitByReference(svc, printer, list, - NULL, &av[optind], &job); - else /* copy the files before return, -c */ - status = papiJobSubmit(svc, printer, list, - NULL, &av[optind], &job); - - papiAttributeListFree(list); - - if (status != PAPI_OK) { - fprintf(stderr, gettext("%s: %s\n"), printer, - verbose_papi_message(svc, status)); - papiJobFree(job); - papiServiceDestroy(svc); - exit(1); - } - - if (((silent == 0) || (dump != 0)) && - ((list = papiJobGetAttributeList(job)) != NULL)) { - int32_t id = -1; - - if (printer == NULL) - papiAttributeListGetString(list, NULL, - "printer-name", &printer); - - papiAttributeListGetInteger(list, NULL, - "job-id-requested", &id); - if (id == -1) { - papiAttributeListGetInteger(list, NULL, "job-id", &id); - } - - printf(gettext("request id is %s-%d "), printer, id); - if (ac != optind) - printf("(%d file(s))\n", ac - optind); - else - printf("(standard input)\n"); - - if (dump != 0) { - printf("job attributes:\n"); - papiAttributeListPrint(stdout, list, "\t"); - printf("\n"); - } - } - - papiJobFree(job); - papiServiceDestroy(svc); - - return (0); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpc.c b/usr/src/cmd/print/bsd-sysv-commands/lpc.c deleted file mode 100644 index a4a89e77cc..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lpc.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: lpc.c 146 2006-03-24 00:26:54Z njacobs $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -typedef int (cmd_handler_t)(papi_service_t, char **); - -static papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - -/* ARGSUSED0 */ -static int -lpc_exit(papi_service_t svc, char **args) -{ - exit(0); - /* NOTREACHED */ - return (0); -} - -static int -lpc_status(papi_service_t svc, char **args) -{ - papi_status_t status; - papi_printer_t p = NULL; - char *pattrs[] = { "printer-state", "printer-state-reasons", - "printer-is-accepting-jobs", NULL }; - char *destination = args[1]; - - status = papiPrinterQuery(svc, destination, pattrs, NULL, &p); - if (status == PAPI_OK) { - papi_attribute_t **list = papiPrinterGetAttributeList(p); - char accepting = 0; - int32_t state = 0; - - printf("%s:\n", destination); - - (void) papiAttributeListGetBoolean(list, NULL, - "printer-is-accepting-jobs", &accepting); - printf(gettext("\tqueueing is %s\n"), - (accepting ? gettext("enabled") : gettext("disabled"))); - - (void) papiAttributeListGetInteger(list, NULL, - "printer-state", &state); - printf("\tprinting is %s\n", - ((state != 0x05) ? gettext("enabled") : - gettext("disabled"))); - - if (state != 0x03) { /* !idle */ - papi_job_t *jobs = NULL; - int i = 0; - - (void) papiPrinterListJobs(svc, destination, NULL, - PAPI_LIST_JOBS_ALL, 0, &jobs); - if (jobs != NULL) { - for (i = 0; jobs[i] != NULL; i++); - papiJobListFree(jobs); - } - printf(gettext("\t%d entries in spool area\n"), i); - } else - printf(gettext("\tno entries\n")); - - if (state == 0x04) - printf(gettext("\tdaemon present\n")); - - } else { - fprintf(stderr, "%s: %s\n", destination, - verbose_papi_message(svc, status)); - return (-1); - } - - papiPrinterFree(p); - - return (0); -} - -static int -lpc_abort(papi_service_t svc, char **args) -{ - papi_status_t status; - char *destination = args[1]; - - if (destination == NULL) { - fprintf(stderr, gettext("Usage: abort (destination)\n")); - return (-1); - } - - status = papiPrinterPause(svc, destination, "paused via lpc abort"); - if (status == PAPI_OK) { - printf(gettext("%s: processing disabled after current job\n"), - destination); - } else { - fprintf(stderr, "%s: %s\n", destination, - verbose_papi_message(svc, status)); - } - - return (0); -} - -static int -lpc_clean(papi_service_t svc, char **args) -{ - papi_status_t status; - papi_job_t *jobs = NULL; - char *destination = args[1]; - - if (destination == NULL) { - fprintf(stderr, gettext("Usage: clean (destination)\n")); - return (-1); - } - - status = papiPrinterPurgeJobs(svc, destination, &jobs); - if (status != PAPI_OK) { - fprintf(stderr, gettext("clean: %s: %s\n"), destination, - verbose_papi_message(svc, status)); - return (-1); - } - - if (jobs != NULL) { - int i; - - for (i = 0; jobs[i] != NULL; i++) - printf(gettext("\t%s-%d: cancelled\n"), destination, - papiJobGetId(jobs[i])); - - papiJobListFree(jobs); - } - - return (0); -} - -static int -lpc_disable(papi_service_t svc, char **args) -{ - papi_status_t status; - char *destination = args[1]; - - if (destination == NULL) { - fprintf(stderr, gettext("Usage: disable: (destination)\n")); - return (-1); - } - - status = papiPrinterDisable(svc, destination, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext("disable: %s: %s\n"), destination, - verbose_papi_message(svc, status)); - return (-1); - } - - return (0); -} - -static int -lpc_enable(papi_service_t svc, char **args) -{ - papi_status_t status; - char *destination = args[1]; - - if (destination == NULL) { - fprintf(stderr, gettext("Usage: enable: (destination)\n")); - return (-1); - } - - status = papiPrinterEnable(svc, destination); - if (status != PAPI_OK) { - fprintf(stderr, gettext("enable: %s: %s\n"), destination, - verbose_papi_message(svc, status)); - return (-1); - } - - return (0); -} - -static int -lpc_restart(papi_service_t svc, char **args) -{ - int rc = 0; - - rc += lpc_disable(svc, args); - rc += lpc_enable(svc, args); - - return (rc); -} - -static int -lpc_start(papi_service_t svc, char **args) -{ - papi_status_t status; - char *destination = args[1]; - - if (destination == NULL) { - fprintf(stderr, gettext("Usage: start (destination)\n")); - return (-1); - } - - status = papiPrinterResume(svc, destination); - if (status != PAPI_OK) { - fprintf(stderr, gettext("start: %s: %s\n"), destination, - verbose_papi_message(svc, status)); - return (-1); - } - - return (0); -} - -static int -lpc_stop(papi_service_t svc, char **args) -{ - papi_status_t status; - char *destination = args[1]; - - if (destination == NULL) { - fprintf(stderr, gettext("Usage: stop (destination)\n")); - return (-1); - } - - status = papiPrinterPause(svc, destination, "paused via lpc"); - if (status != PAPI_OK) { - fprintf(stderr, gettext("stop: %s: %s\n"), destination, - verbose_papi_message(svc, status)); - return (-1); - } - - return (0); -} - -static int -lpc_topq(papi_service_t svc, char **args) -{ - papi_status_t status; - char *destination = args[1]; - char *idstr = args[2]; - int32_t id; - - if (destination == NULL || idstr == NULL) { - fprintf(stderr, gettext("Usage: topq (destination) (id)\n")); - return (-1); - } - id = atoi(idstr); - - status = papiJobPromote(svc, destination, id); - if (status != PAPI_OK) { - fprintf(stderr, gettext("topq: %s-%d: %s\n"), destination, id, - verbose_papi_message(svc, status)); - return (-1); - } - - return (0); -} - -static int -lpc_up(papi_service_t svc, char **args) -{ - int rc = 0; - - rc += lpc_enable(svc, args); - rc += lpc_start(svc, args); - - return (rc); -} - -static int -lpc_down(papi_service_t svc, char **args) -{ - int rc = 0; - - rc += lpc_disable(svc, args); - rc += lpc_stop(svc, args); - - return (rc); -} - -static int lpc_help(papi_service_t svc, char **args); /* forward reference */ - -static char help_help[] = "get help on commands"; -static char help_exit[] = "exit lpc"; -static char help_status[] = "show status of daemon and queue"; -static char help_abort[] = - "disable print queue terminating any active job processing"; -static char help_clean[] = "remove all jobs from a queue"; -static char help_disable[] = "turn off spooling to a queue"; -static char help_down[] = - "turn off queueing and printing for a queue and set a reason"; -static char help_enable[] = "turn on spooling to a queue"; -static char help_restart[] = "restart job processing for a queue"; -static char help_start[] = "turn on printing from a queue"; -static char help_stop[] = "turn off printing from a queue"; -static char help_up[] = "turn on queueing and printing for a queue"; -static char help_topq[] = "put a job at the top of the queue"; - -static struct { - char *cmd; - int (*handler)(papi_service_t svc, char **args); - char *help_string; - int num_args; -} cmd_tab[] = { - { "?", lpc_help, help_help, 0 }, - { "help", lpc_help, help_help, 0 }, - { "exit", lpc_exit, help_exit, 0 }, - { "quit", lpc_exit, help_exit, 0 }, - { "status", lpc_status, help_status, 1 }, - { "abort", lpc_abort, help_abort, 1 }, - { "clean", lpc_clean, help_clean, 1 }, - { "disable", lpc_disable, help_disable, 1 }, - { "down", lpc_down, help_down, 2 }, - { "enable", lpc_enable, help_enable, 1 }, - { "restart", lpc_restart, help_restart, 1 }, - { "start", lpc_start, help_start, 1 }, - { "stop", lpc_stop, help_stop, 1 }, - { "up", lpc_up, help_up, 1 }, - { "topq", lpc_topq, help_topq, 2 }, - { NULL, NULL, NULL, 0 } -}; - -static int -lpc_handler(char *cmd, cmd_handler_t **handler) -{ - int i; - - for (i = 0; cmd_tab[i].cmd != NULL; i++) - if (strcmp(cmd, cmd_tab[i].cmd) == 0) { - *handler = cmd_tab[i].handler; - return (cmd_tab[i].num_args); - } - return (-1); -} - -static char * -lpc_helptext(char *cmd) -{ - int i; - - for (i = 0; cmd_tab[i].cmd != NULL; i++) - if (strcmp(cmd, cmd_tab[i].cmd) == 0) - return (gettext(cmd_tab[i].help_string)); - return (NULL); -} - -/* ARGSUSED0 */ -static int -lpc_help(papi_service_t svc, char **args) -{ - if (args[1] == NULL) { - int i; - - printf(gettext("Commands are:\n\n")); - for (i = 0; cmd_tab[i].cmd != NULL; i++) { - printf("\t%s", cmd_tab[i].cmd); - if ((i % 7) == 6) - printf("\n"); - } - if ((i % 7) != 6) - printf("\n"); - } else { - char *helptext = lpc_helptext(args[1]); - - if (helptext == NULL) - helptext = gettext("no such command"); - - printf("%s: %s\n", args[1], helptext); - } - - return (0); -} - -static int -process_one(int (*handler)(papi_service_t, char **), char **av, int expected) -{ - int rc = -1; - papi_status_t status = PAPI_OK; - papi_service_t svc = NULL; - char *printer = av[1]; - - if ((printer != NULL) && (expected != 0)) { - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - } - } - - if (status == PAPI_OK) - rc = handler(svc, av); - - if (svc != NULL) - papiServiceDestroy(svc); - - return (rc); -} - -static int -process_all(int (*handler)(papi_service_t, char **), char **av, int expected) -{ - papi_status_t status; - papi_service_t svc = NULL; - char **printers; - int rc = 0; - - status = papiServiceCreate(&svc, NULL, NULL, NULL, NULL, - encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext("Failed to contact service: %s\n"), - verbose_papi_message(svc, status)); - return (-1); - } - - if ((printers = interest_list(svc)) != NULL) { - int i; - - for (i = 0; printers[i] != NULL; i++) { - av[1] = printers[i]; - rc += process_one(handler, av, expected); - } - } - - papiServiceDestroy(svc); - - return (rc); -} - -static int -process(int ac, char **av) -{ - int (*handler)(papi_service_t, char **) = NULL; - int num_args = -1; - - char *printer = av[1]; - int rc = -1; - - if ((num_args = lpc_handler(av[0], &handler)) < 0) { - printf(gettext("%s: invalid command\n"), av[0]); - return (-1); - } - - if (((ac == 0) && (num_args == 1)) || - ((printer != NULL) && strcmp(printer, "all") == 0)) - rc = process_all(handler, av, num_args); - else if (num_args < ac) { - int i; - char *argv[4]; - - memset(argv, 0, sizeof (argv)); - argv[0] = av[0]; - - if (strcmp(av[0], "topq") == 0) { - argv[1] = av[1]; - for (i = 2; i <= ac; i++) { - argv[2] = av[i]; - process_one(handler, argv, num_args); - } - } else - for (i = 1; i <= ac; i++) { - argv[1] = av[i]; - process_one(handler, argv, num_args); - } - } else - rc = process_one(handler, av, num_args); - - return (rc); -} - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s [ command [ parameter...]]\n"), - name); - exit(1); -} - -static void -lpc_shell() -{ - for (;;) { - char line[256]; - char **av = NULL; - int ac = 0; - - /* prompt */ - fprintf(stdout, "lpc> "); - fflush(stdout); - - /* get command */ - if (fgets(line, sizeof (line), stdin) == NULL) - exit(1); - if ((av = strsplit(line, " \t\n")) != NULL) - for (ac = 0; av[ac] != NULL; ac++); - else - continue; - - if (ac > 0) - (void) process(ac - 1, av); - free(av); - } -} - -int -main(int ac, char *av[]) -{ - int result = 0; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "E")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_ALWAYS; - break; - default: - usage(av[0]); - } - - if (optind == ac) - lpc_shell(); - else - result = process(ac - optind - 1, &av[optind]); - - return (result); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpmove.c b/usr/src/cmd/print/bsd-sysv-commands/lpmove.c deleted file mode 100644 index 15cb076ef1..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lpmove.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -/* $Id: lpmove.c 146 2006-03-24 00:26:54Z njacobs $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s [request-id] (destination)\n" - " %s (source) (destination)\n"), name, name); - exit(1); -} - -static int -move_job(papi_service_t svc, char *src, int32_t id, char *dest) -{ - int result = 0; - papi_status_t status; - char *mesg = gettext("moved"); - - status = papiJobMove(svc, src, id, dest); - if (status != PAPI_OK) { - mesg = (char *)verbose_papi_message(svc, status); - result = -1; - } - fprintf(stderr, gettext("%s-%d to %s: %s\n"), src, id, dest, mesg); - - return (result); -} - -int -main(int ac, char *av[]) -{ - int exit_code = 0; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - char *destination = NULL; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "E:")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - default: - usage(av[0]); - } - - if (optind >= ac - 1) - usage(av[0]); - - destination = av[--ac]; - - for (c = optind; c < ac; c++) { - papi_status_t status; - papi_service_t svc = NULL; - papi_job_t *jobs = NULL; - char *printer = NULL; - int32_t id = -1; - - (void) get_printer_id(av[c], &printer, &id); - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit(1); - } - - if (id != -1) { /* it's a job */ - if (move_job(svc, printer, id, destination) < 0) - exit_code = 1; - } else { /* it's a printer */ - char message[128]; - int count = 0; - - snprintf(message, sizeof (message), "moved jobs to %s", - destination); - status = papiPrinterPause(svc, printer, message); - if (status != PAPI_OK) { - /* - * If the user is denied the permission - * to disable then return appropriate msg - */ - char *result = NULL; - - result = papiServiceGetStatusMessage(svc); - - if (result != NULL) { - /* - * Check if user is denied - * the permission - */ - if (strstr(result, "permission denied") - != NULL) { - /* - * user is denied - * permission - */ - fprintf(stderr, "UX:lpmove: "); - fprintf(stderr, - gettext("ERROR: ")); - fprintf(stderr, gettext("You " - "aren't allowed to do" - " that.")); - fprintf(stderr, "\n\t"); - fprintf(stderr, - gettext("TO FIX")); - fprintf(stderr, ": "); - fprintf(stderr, gettext("You " - "must be logged in as " - "\"lp\" or \"root\".")); - fprintf(stderr, "\n"); - exit_code = 1; - } else { - fprintf(stderr, gettext( - "Reject %s: %s\n"), - printer, - verbose_papi_message( - svc, status)); - exit_code = 1; - } - } else { - fprintf(stderr, gettext( - "Reject %s: %s\n"), - printer, - verbose_papi_message(svc, status)); - exit_code = 1; - } - } else { - printf(gettext( - "destination %s is not accepting"\ - " requests\n"), printer); - - status = papiPrinterListJobs(svc, printer, NULL, - 0, 0, &jobs); - if (status != PAPI_OK) { - fprintf(stderr, gettext("Jobs %s:"\ - " %s\n"), - printer, - verbose_papi_message(svc, status)); - exit_code = 1; - } - - printf(gettext("move in progress ...\n")); - while ((jobs != NULL) && (*jobs != NULL)) { - id = papiJobGetId(*jobs++); - if (move_job(svc, printer, - id, destination) < 0) - exit_code = 1; - else - count++; - } - printf(gettext( - "total of %d requests moved"\ - " from %s to %s\n"), - count, printer, destination); - - papiJobListFree(jobs); - } - } - - papiServiceDestroy(svc); - } - - return (exit_code); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpq.c b/usr/src/cmd/print/bsd-sysv-commands/lpq.c deleted file mode 100644 index 188a5669d6..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lpq.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: lpq.c 146 2006-03-24 00:26:54Z njacobs $ */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, gettext("Usage: %s [-P printer] (user|id ...)\n"), - name); - exit(1); -} - -static void -clear_screen() -{ - static char buf[32]; - - /* quick and dirty for now, this should be fixed real soon */ - if (buf[0] == '\0') { - FILE *fp = popen("/bin/tput clear", "r"); - if (fp != NULL) { - fgets(buf, sizeof (buf), fp); - fclose(fp); - } - } - printf("%s", buf); -} - -int -main(int ac, char *av[]) -{ - char *printer = NULL; - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int format = 3; /* lpq short format */ - int interval = 0; - int num_jobs; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "EP:l")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - case 'P': - printer = optarg; - break; - case 'l': - format = 4; /* lpq long format */ - break; - default: - usage(av[0]); - } - - if ((optind < ac) && (av[optind][0] == '+')) - interval = atoi(av[optind++]); - - if ((printer == NULL) && - ((printer = getenv("PRINTER")) == NULL) && - ((printer = getenv("LPDEST")) == NULL)) - printer = DEFAULT_DEST; - - status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), printer, - verbose_papi_message(svc, status)); - papiServiceDestroy(svc); - exit(1); - } - - do { - if (interval != 0) - clear_screen(); - - num_jobs = berkeley_queue_report(svc, stdout, printer, format, - ac - optind, &av[optind]); - - if ((interval != 0) && (num_jobs > 0)) - sleep(interval); - } while ((interval > 0) && (num_jobs > 0)); - - papiServiceDestroy(svc); - - return (0); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpr.c b/usr/src/cmd/print/bsd-sysv-commands/lpr.c deleted file mode 100644 index 547e0df36f..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lpr.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: lpr.c 146 2006-03-24 00:26:54Z njacobs $ */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -#ifdef HAVE_LIBMAGIC /* for mimetype auto-detection */ -#include <magic.h> -#endif /* HAVE_LIBMAGIC */ - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s [-P printer] [-# copies] [-C class] " - "[-J job] [-T title] " - "[-p [-i indent] [-w width]] " - "[-1|-2|-3|-4 font] [-m] [-h] [-s] " - "[-filter_option] [file ..]\n"), name); - exit(1); -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_attribute_t **list = NULL; - papi_job_t job = NULL; - int exit_code = 0; - char *printer = NULL; - char prefetch[3]; - int prefetch_len = sizeof (prefetch); - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int dump = 0; - int validate = 0; - int remove = 0; - int copy = 1; /* default is to copy the data */ - char *document_format = "text/plain"; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, - "EP:#:C:DVJ:T:w:i:hplrstdgvcfmn1:2:3:4:")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - case 'P': - printer = optarg; - break; - case '#': - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "copies", atoi(optarg)); - break; - case 'C': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-class", optarg); - break; - case 'D': - dump = 1; - break; - case 'J': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-name", optarg); - break; - case 'T': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "pr-title", optarg); - break; - case 'p': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-pr"); - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "pr-filter", 1); - break; - case 'i': - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "pr-indent", atoi(optarg)); - break; - case 'w': - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, - "pr-width", atoi(optarg)); - break; - case 'h': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-sheets", "none"); - break; - case 'l': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/octet-stream"); - break; - case 'o': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/postscript"); - break; - case 'c': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-cif"); - break; - case 'd': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-dvi"); - break; - case 'f': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-fortran"); - break; - case 'g': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-plot"); - break; - case 'n': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-ditroff"); - break; - case 't': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-troff"); - break; - case 'v': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", "application/x-raster"); - break; - case 'm': - papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL, - "rfc-1179-mail", 1); - break; - case 'r': - remove = 1; - break; - case 's': - copy = 0; - break; - case 'V': /* validate */ - validate = 1; - break; - case '1': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-r", optarg); - break; - case '2': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-i", optarg); - break; - case '3': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-b", optarg); - break; - case '4': - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "rfc-1179-font-s", optarg); - break; - default: - usage(av[0]); - } - - if ((printer == NULL) && - ((printer = getenv("PRINTER")) == NULL) && - ((printer = getenv("LPDEST")) == NULL)) - printer = DEFAULT_DEST; - - if (((optind + 1) == ac) && (strcmp(av[optind], "-") == 0)) - optind = ac; - - if (optind != ac) { - /* get the mime type of the file data */ -#ifdef MAGIC_MIME - magic_t ms; - - if ((ms = magic_open(MAGIC_MIME)) != NULL) { - document_format = magic_file(ms, av[optind]); - magic_close(ms); - } -#else - if (is_postscript(av[optind]) == 1) - document_format = "application/postscript"; -#endif - } else { - if (is_postscript_stream(0, prefetch, &prefetch_len) == 1) - document_format = "application/postscript"; - } - - papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1); - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "document-format", document_format); - papiAttributeListAddString(&list, PAPI_ATTR_EXCL, - "job-sheets", "standard"); - - status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), printer, - verbose_papi_message(svc, status)); - exit(1); - } - - if (validate == 1) /* validate the request can be processed */ - status = papiJobValidate(svc, printer, list, - NULL, &av[optind], &job); - else if (optind == ac) /* no file list, use stdin */ - status = jobSubmitSTDIN(svc, printer, prefetch, prefetch_len, - list, &job); - else if (copy == 0) /* reference the files in the job, default */ - status = papiJobSubmitByReference(svc, printer, list, - NULL, &av[optind], &job); - else /* copy the files before return, -c */ - status = papiJobSubmit(svc, printer, list, - NULL, &av[optind], &job); - - papiAttributeListFree(list); - - if (status != PAPI_OK) { - fprintf(stderr, gettext("%s: %s\n"), printer, - verbose_papi_message(svc, status)); - papiJobFree(job); - papiServiceDestroy(svc); - exit(1); - } - - if (dump != 0) { - list = papiJobGetAttributeList(job); - printf("job attributes:\n"); - papiAttributeListPrint(stdout, list, "\t"); - printf("\n"); - } - - papiJobFree(job); - papiServiceDestroy(svc); - - return (exit_code); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lprm.c b/usr/src/cmd/print/bsd-sysv-commands/lprm.c deleted file mode 100644 index 841a5da811..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lprm.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: lprm.c 146 2006-03-24 00:26:54Z njacobs $ */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, gettext("Usage: %s [-P printer] (user|id ...)\n"), - name); - exit(1); -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - char *printer = NULL; - int c; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "EP:")) != EOF) - switch (c) { - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - case 'P': - printer = optarg; - break; - default: - usage(av[0]); - } - - if ((printer == NULL) && - ((printer = getenv("PRINTER")) == NULL) && - ((printer = getenv("LPDEST")) == NULL)) - printer = DEFAULT_DEST; - - status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - papiServiceDestroy(svc); - return (1); - } - - berkeley_cancel_request(svc, stdout, printer, - ac - optind, &av[optind]); - - papiServiceDestroy(svc); - - return (0); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c deleted file mode 100644 index 6f666bcc03..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c +++ /dev/null @@ -1,1444 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: lpstat.c 173 2006-05-25 04:52:06Z njacobs $ */ - - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <ctype.h> -#include <pwd.h> -#include <papi.h> -#include <uri.h> -#include "common.h" -#include "lp.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, gettext("Usage: %s [-d] [-r] [-s] [-t] [-a [list]] " - "[-c [list]] [-o [list] [-l]] [-R [list] [-l]] " - "[-p [list] [-D] [-l]] [-v [list]] [-S [list] [-l]] " - "[-f [list] [-l]] [-u list]\n"), - name); - exit(1); -} - -static char * -nctime(time_t *t) -{ - static char buf[64]; - struct tm *tm = localtime(t); - - (void) strftime(buf, sizeof (buf), "%c", tm); - - return (buf); -} - -static char * -printer_name(papi_printer_t printer) -{ - papi_attribute_t **attributes = papiPrinterGetAttributeList(printer); - char *result = NULL; - - if (attributes != NULL) - papiAttributeListGetString(attributes, NULL, - "printer-name", &result); - - return (result); -} - -static int -lpstat_default_printer(papi_encryption_t encryption) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_printer_t p = NULL; - char *name = NULL; - - status = papiServiceCreate(&svc, NULL, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status == PAPI_OK) { - char *req[] = { "printer-name", NULL }; - - status = papiPrinterQuery(svc, DEFAULT_DEST, req, NULL, &p); - if (p != NULL) - name = printer_name(p); - } - if (name != NULL) - printf(gettext("system default printer: %s\n"), name); - else - printf(gettext("no system default destination\n")); - papiPrinterFree(p); - papiServiceDestroy(svc); - - return (0); -} - -static int -lpstat_service_status(papi_encryption_t encryption) -{ - papi_status_t status; - papi_service_t svc = NULL; - char *name = NULL; - - if (((name = getenv("PAPI_SERVICE_URI")) == NULL) && - ((name = getenv("IPP_SERVER")) == NULL) && - ((name = getenv("CUPS_SERVER")) == NULL)) - name = DEFAULT_SERVICE_URI; - - status = papiServiceCreate(&svc, name, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status != PAPI_OK) { - printf(gettext("scheduler is not running\n")); - } else - printf(gettext("scheduler is running\n")); - papiServiceDestroy(svc); - - return (0); -} - -static char * -get_device_uri(papi_service_t svc, char *name) -{ - papi_status_t status; - papi_printer_t p = NULL; - char *keys[] = { "device-uri", NULL }; - char *result = NULL; - - status = papiPrinterQuery(svc, name, keys, NULL, &p); - if ((status == PAPI_OK) && (p != NULL)) { - papi_attribute_t **attrs = papiPrinterGetAttributeList(p); - - (void) papiAttributeListGetString(attrs, NULL, - "device-uri", &result); - if (result != NULL) - result = strdup(result); - - papiPrinterFree(p); - } - - return (result); -} - -static void -print_description(papi_attribute_t **list, char *printer_name) -{ - char *str = ""; - - (void) papiAttributeListGetString(list, NULL, - "printer-info", &str); - - /* - * If no printer-info is read then - * by default the printer-info is <printer-name>@<server> - */ - if (str[0] == '\0') { - char *uri = NULL; - uri_t *u = NULL; - - (void) papiAttributeListGetString(list, NULL, - "printer-uri-supported", &uri); - - if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { - char *nodename = localhostname(); - - if ((u->host == NULL) || - (strcasecmp(u->host, "localhost") == 0) || - (strcasecmp(u->host, nodename) == 0)) - printf(gettext("\tDescription:\n")); - else - printf(gettext("\tDescription: %s@%s\n"), - printer_name, u->host); - - uri_free(u); - } else - printf(gettext("\tDescription:\n")); - } else - printf(gettext("\tDescription: %s\n"), str); -} - -static char *report_device_keys[] = { "printer-name", "printer-uri-supported", - NULL }; -/* ARGSUSED2 */ -static int -report_device(papi_service_t svc, char *name, papi_printer_t printer, - int verbose, int description) -{ - papi_status_t status; - papi_attribute_t **attrs = papiPrinterGetAttributeList(printer); - char *uri = NULL; - char *device = NULL; - uri_t *u = NULL; - - if (name == NULL) { - status = papiAttributeListGetString(attrs, NULL, - "printer-name", &name); - if (status != PAPI_OK) - status = papiAttributeListGetString(attrs, NULL, - "printer-uri-supported", &name); - } - - if (name == NULL) - return (-1); - - (void) papiAttributeListGetString(attrs, NULL, - "printer-uri-supported", &uri); - - if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { - char *nodename = localhostname(); - - if ((u->host == NULL) || - (strcasecmp(u->host, "localhost") == 0) || - (strcasecmp(u->host, nodename) == 0)) - device = get_device_uri(svc, name); - - if (device != NULL) { - printf(gettext("device for %s: %s\n"), name, device); - return (0); - } else if (uri != NULL) { - printf(gettext("system for %s: %s (as %s)\n"), name, - u->host?u->host:"localhost", uri); - return (0); - } - - uri_free(u); - } - - return (0); -} - -static char *report_accepting_keys[] = { "printer-name", - "printer-uri-supported", "printer-is-accepting-jobs", - "printer-up-time", "printer-state-time", - "lpsched-reject-date", "lpsched-reject-reason", NULL }; -/* ARGSUSED2 */ -static int -report_accepting(papi_service_t svc, char *name, papi_printer_t printer, - int verbose, int description) -{ - papi_status_t status; - papi_attribute_t **attrs = papiPrinterGetAttributeList(printer); - time_t curr; - char boolean = PAPI_FALSE; - - if (name == NULL) { - status = papiAttributeListGetString(attrs, NULL, - "printer-name", &name); - if (status != PAPI_OK) - status = papiAttributeListGetString(attrs, NULL, - "printer-uri-supported", &name); - } - if (name == NULL) - return (-1); - - (void) papiAttributeListGetBoolean(attrs, NULL, - "printer-is-accepting-jobs", &boolean); - (void) time(&curr); - (void) papiAttributeListGetDatetime(attrs, NULL, - "printer-up-time", &curr); - (void) papiAttributeListGetDatetime(attrs, NULL, - "printer-state-time", &curr); - (void) papiAttributeListGetDatetime(attrs, NULL, - "lpsched-reject-date", &curr); - - if (boolean == PAPI_TRUE) { - printf(gettext("%s accepting requests since %s\n"), - name, nctime(&curr)); - } else { - char *reason = "unknown reason"; - - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-reject-reason", &reason); - - printf(gettext("%s not accepting requests since %s\n\t%s\n"), - name, nctime(&curr), reason); - } - - return (0); -} - -static char *report_class_keys[] = { "printer-name", "printer-uri-supported", - "member-names", NULL }; -/* ARGSUSED2 */ -static int -report_class(papi_service_t svc, char *name, papi_printer_t printer, - int verbose, int description) -{ - papi_status_t status; - papi_attribute_t **attrs = papiPrinterGetAttributeList(printer); - char *member = NULL; - void *iter = NULL; - - status = papiAttributeListGetString(attrs, &iter, - "member-names", &member); - if (status == PAPI_NOT_FOUND) /* it's not a class */ - return (0); - - if (name == NULL) { - status = papiAttributeListGetString(attrs, NULL, - "printer-name", &name); - if (status != PAPI_OK) - status = papiAttributeListGetString(attrs, NULL, - "printer-uri-supported", &name); - } - if (name == NULL) - return (-1); - - printf(gettext("members of class %s:\n\t%s\n"), name, member); - while (papiAttributeListGetString(attrs, &iter, NULL, &member) - == PAPI_OK) - printf("\t%s\n", member); - - return (0); -} - -static int -get_remote_hostname(papi_attribute_t **attrs, char **host) -{ - char *uri = NULL; - uri_t *u; - char *nodename; - - *host = NULL; - (void) papiAttributeListGetString(attrs, NULL, - "job-originating-host-name", host); - (void) papiAttributeListGetString(attrs, NULL, - "printer-uri-supported", &uri); - if (*host == NULL) { - if (uri != NULL) { - if (uri_from_string(uri, &u) == 0) { - if (u->host == NULL) { - uri_free(u); - return (0); - } - *host = strdup(u->host); - uri_free(u); - } else { - return (0); - } - } else { - return (0); - } - } - nodename = localhostname(); - if ((strcasecmp(*host, "localhost") == 0) || - (strcasecmp(*host, nodename) == 0)) { - return (0); - } - return (1); -} - -static char *report_printer_keys[] = { "printer-name", - "printer-uri-supported", "printer-state", - "printer-up-time", "printer-state-time", - "lpsched-disable-date", "printer-state-reasons", - "lpsched-disable-reason", NULL }; -/* ARGSUSED2 */ -static int -report_printer(papi_service_t svc, char *name, papi_printer_t printer, - int verbose, int description) -{ - papi_status_t status; - papi_attribute_t **attrs = papiPrinterGetAttributeList(printer); - time_t curr; - int32_t pstat = 0; - char *member = NULL; - papi_job_t *j = NULL; - - status = papiAttributeListGetString(attrs, NULL, - "member-names", &member); - if (status == PAPI_OK) /* it's a class */ - return (0); - - if (name == NULL) { - status = papiAttributeListGetString(attrs, NULL, - "printer-name", &name); - if (status != PAPI_OK) - status = papiAttributeListGetString(attrs, NULL, - "printer-uri-supported", &name); - } - if (name == NULL) - return (-1); - - printf(gettext("printer %s "), name); - - status = papiAttributeListGetInteger(attrs, NULL, - "printer-state", &pstat); - - switch (pstat) { - case 0x03: /* idle */ - printf(gettext("is idle. enabled")); - break; - case 0x04: /* processing */ - case 0x06: /* faulted printing */ - status = papiPrinterListJobs(svc, name, NULL, - 0, 0, &j); - - if (status == PAPI_OK) { - if (j != NULL) { - int i = 0; - int32_t jobid = 0; - int32_t jstate = 0; - - for (i = 0; j[i] != NULL; ++i) { - papi_attribute_t **attr = - papiJobGetAttributeList(j[i]); - - papiAttributeListGetInteger(attr, - NULL, "job-state", &jstate); - papiAttributeListGetInteger(attr, - NULL, "job-id", &jobid); - /* - * For lpd protocol "job-id-requested" - * should be read. - */ - papiAttributeListGetInteger(attr, - NULL, "job-id-requested", &jobid); - - /* - * When lpd protocol is used job-state - * cannot be retrieved, therefore - * job-state will be 0. - * When ipp protocol is used, the - * active/printing job-state will be - * RS_PRINTING (0x0008) post s10u5. - * For pre-s10u5 job-state will be - * RS_ACTIVE (0x05). So print only when - * the job-state is RS_PRINTING (0x0008) - * or RS_ACTIVE (0x05) or 0 - */ - if ((jstate == 0x0008) || - (jstate == 0x05) || - (jstate == 0)) { - if (pstat == 0x04) - printf(gettext - ("now printing"\ - " %s-%d. enabled"), - name, jobid); - if (pstat == 0x06) - printf(gettext - ("faulted printing"\ - " %s-%d. enabled"), - name, jobid); - break; - } - } - papiJobListFree(j); - } - } - break; - case 0x05: /* stopped */ - printf(gettext("disabled")); - break; - case 0x07: /* faulted printer */ - printf(gettext("faulted. enabled")); - break; - case 0x08: /* waiting for auto retry */ - printf(gettext("waiting for auto-retry.")); - break; - default: - printf(gettext("unknown state(0x%x)."), pstat); - break; - } - - if (pstat == 0x08) - printf(gettext(" available.\n")); - else { - (void) time(&curr); - (void) papiAttributeListGetDatetime(attrs, NULL, - "printer-up-time", &curr); - (void) papiAttributeListGetDatetime(attrs, NULL, - "printer-state-time", &curr); - (void) papiAttributeListGetDatetime(attrs, NULL, - "lpsched-disable-date", &curr); - printf(gettext(" since %s. available.\n"), nctime(&curr)); - } - - if ((pstat == 0x05) || - (pstat == 0x06) || - (pstat == 0x07) || - (pstat == 0x08)) { - char *reason = "unknown reason"; - - (void) papiAttributeListGetString(attrs, NULL, - "printer-state-reasons", &reason); - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-disable-reason", &reason); - printf(gettext("\t%s\n"), reason); - } - - if (verbose == 1) { - void *iter; - char *str; - char *host = NULL; - - if ((get_remote_hostname(attrs, &host)) != 0) { - (void) printf( - gettext("\tRemote Name: %s\n\tRemote Server: " - "%s\n"), name, host); - free(host); - return (0); - } - str = ""; - (void) papiAttributeListGetString(attrs, NULL, - "form-ready", &str); - printf(gettext("\tForm mounted: %s\n"), str); - - str = ""; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "document-format-supported", &str); - printf(gettext("\tContent types: %s"), str); - while (papiAttributeListGetString(attrs, &iter, NULL, &str) - == PAPI_OK) - printf(", %s", str); - printf("\n"); - - /* Display the printer description */ - print_description(attrs, name); - - str = ""; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "lpsched-printer-type", &str); - printf(gettext("\tPrinter types: %s"), str); - while (papiAttributeListGetString(attrs, &iter, NULL, &str) - == PAPI_OK) - printf(", %s", str); - printf("\n"); - - str = ""; - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-dial-info", &str); - printf(gettext("\tConnection: %s\n"), - ((str[0] == '\0') ? gettext("direct") : str)); - - str = ""; - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-interface-script", &str); - printf(gettext("\tInterface: %s\n"), str); - - str = NULL; - (void) papiAttributeListGetString(attrs, NULL, - "ppd-file-uri", &str); - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-ppd-source-path", &str); - if (str != NULL) - printf(gettext("\tPPD: %s\n"), str); - - str = NULL; - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-fault-alert-command", &str); - if (str != NULL) - printf(gettext("\tOn fault: %s\n"), str); - - str = ""; - (void) papiAttributeListGetString(attrs, NULL, - "lpsched-fault-recovery", &str); - printf(gettext("\tAfter fault: %s\n"), - ((str[0] == '\0') ? gettext("continue") : str)); - - str = "(all)"; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "requesting-user-name-allowed", &str); - printf(gettext("\tUsers allowed:\n\t\t%s\n"), - ((str[0] == '\0') ? gettext("(none)") : str)); - if ((str != NULL) && (str[0] != '\0')) - while (papiAttributeListGetString(attrs, &iter, NULL, - &str) == PAPI_OK) - printf("\t\t%s\n", str); - - str = NULL; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "requesting-user-name-denied", &str); - if (str != NULL) { - printf(gettext("\tUsers denied:\n\t\t%s\n"), - ((str[0] == '\0') ? gettext("(none)") : str)); - if ((str != NULL) && (str[0] != '\0')) - while (papiAttributeListGetString(attrs, &iter, - NULL, &str) == PAPI_OK) - printf("\t\t%s\n", str); - } - - str = "none"; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "form-supported", &str); - printf(gettext("\tForms allowed:\n\t\t(%s)\n"), - ((str[0] == '\0') ? gettext("none") : str)); - if ((str != NULL) && (str[0] != '\0')) - while (papiAttributeListGetString(attrs, &iter, NULL, - &str) == PAPI_OK) - printf("\t\t(%s)\n", str); - - str = ""; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "media-supported", &str); - printf(gettext("\tMedia supported:\n\t\t%s\n"), - ((str[0] == '\0') ? gettext("(none)") : str)); - if ((str != NULL) && (str[0] != '\0')) - while (papiAttributeListGetString(attrs, &iter, NULL, - &str) == PAPI_OK) - printf("\t\t%s\n", str); - - str = ""; - (void) papiAttributeListGetString(attrs, NULL, - "job-sheets-supported", &str); - if ((strcasecmp(str, "none")) == 0) - str = gettext("page never printed"); - else if (strcasecmp(str, "optional") == 0) - str = gettext("not required"); - else - str = gettext("required"); - - printf(gettext("\tBanner %s\n"), str); - - - str = ""; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "lpsched-print-wheels", &str); - printf(gettext("\tCharacter sets:\n\t\t%s\n"), - ((str[0] == '\0') ? gettext("(none)") : str)); - if ((str != NULL) && (str[0] != '\0')) - while (papiAttributeListGetString(attrs, &iter, NULL, - &str) == PAPI_OK) - printf("\t\t%s\n", str); - - printf(gettext("\tDefault pitch:\n")); - printf(gettext("\tDefault page size:\n")); - printf(gettext("\tDefault port setting:\n")); - - str = ""; - iter = NULL; - (void) papiAttributeListGetString(attrs, &iter, - "lpsched-options", &str); - if (str != NULL) { - printf(gettext("\tOptions: %s"), str); - while (papiAttributeListGetString(attrs, &iter, NULL, - &str) == PAPI_OK) - printf(", %s", str); - printf("\n"); - } - - } else if (description == 1) - /* Display printer description */ - print_description(attrs, name); - else if (verbose > 1) - papiAttributeListPrint(stdout, attrs, "\t"); - - if (verbose > 0) - printf("\n"); - - return (0); -} - -static int -printer_query(char *name, int (*report)(papi_service_t, char *, papi_printer_t, - int, int), papi_encryption_t encryption, - int verbose, int description) -{ - int result = 0, i = 0; - papi_status_t status; - papi_service_t svc = NULL; - char **list = getlist(name, LP_WS, LP_SEP); - - if (list == NULL) { - list = (char **)malloc(sizeof (char *)); - list[0] = name; - } - - /* - * The for loop executes once for every printer - * entry in list. If list is NULL that implies - * name is also NULL, the loop runs only one time. - */ - - for (i = 0; name == NULL || list[i] != NULL; i++) { - name = list[i]; - - status = papiServiceCreate(&svc, name, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - if (status == PAPI_NOT_FOUND) - fprintf(stderr, - gettext("%s: unknown printer\n"), - name ? name : "(NULL)"); - else - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - name ? name : "(NULL)", - verbose_papi_message(svc, status)); - papiServiceDestroy(svc); - result--; - continue; - } - - if (name == NULL) { /* all */ - char **interest = interest_list(svc); - - if (interest != NULL) { - int i; - - for (i = 0; interest[i] != NULL; i++) - result += printer_query(interest[i], - report, encryption, verbose, - description); - } - } else { - papi_printer_t printer = NULL; - char **keys = NULL; - - /* - * Limit the query to only required data - * to reduce the need to go remote for - * information. - */ - if (report == report_device) - keys = report_device_keys; - else if (report == report_class) - keys = report_class_keys; - else if (report == report_accepting) - keys = report_accepting_keys; - else if ((report == report_printer) && (verbose == 0)) - keys = report_printer_keys; - - status = papiPrinterQuery(svc, name, keys, - NULL, &printer); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to get printer info for %s: %s\n"), - name, verbose_papi_message(svc, status)); - papiServiceDestroy(svc); - result--; - continue; - } - - if (printer != NULL) - result += report(svc, name, printer, verbose, - description); - - papiPrinterFree(printer); - } - - papiServiceDestroy(svc); - - if (name == NULL) - break; - } - - freelist(list); - - return (result); -} - -static int -match_user(char *user, char **list) -{ - int i; - - for (i = 0; list[i] != NULL; i++) { - if (strcmp(user, list[i]) == 0) - return (0); - } - - return (-1); -} - -static char **users = NULL; - -static int -report_job(char *printer, papi_job_t job, int show_rank, int verbose) -{ - papi_attribute_t **attrs = papiJobGetAttributeList(job); - time_t clock = 0; - char date[24]; - char request[26]; - char *user = "unknown"; - char *host = NULL; - int32_t size = 0; - int32_t jstate = 0; - char User[50]; - - char *destination = "unknown"; - int32_t id = -1; - static int check = 0; - static char *uri = NULL; - static char *puri = NULL; /* printer-uri */ - static char *pname = NULL; /* printer-name */ - - (void) papiAttributeListGetString(attrs, NULL, - "job-originating-user-name", &user); - - if ((users != NULL) && (match_user(user, users) < 0)) - return (0); - - (void) papiAttributeListGetString(attrs, NULL, - "job-originating-host-name", &host); - - /* - * When lpstat is called for multiple printers - * internally the function 'report_job' gets - * called multiple times with different printer-names. - * The following block of code handles the case when lpstat is - * executed for multiple printers. In other words when 'report_job' - * is called multiple times for different printers for - * one lpstat command - * For e.g: lpstat printer1 printer2 printer3 - */ - if (pname == NULL) { - /* - * When lpstat is queried for the first time - * pname is NULL so this part of the code gets executed. - * Read the attribute "job-printer-uri" - * first time - */ - (void) papiAttributeListGetString(attrs, NULL, - "job-printer-uri", &uri); - - if (printer != NULL) { - /* - * Set pname to the printer that is being - * queried so that this can be used later - * if 'report_job' is called multiple times for - * different printers for one lpstat command - */ - pname = printer; - } - - if (uri != NULL) { - /* - * Set puri so that "job-printer-uri" corresponding - * to a particular printer can be used later when - * lpstat is queried for the same printer as - * "job-printer-uri" for a printer is read just once. - */ - puri = strdup(uri); - } - } else { - /* - * This part of the code will get executed when - * 'report_job' is called more than once for the same - * lpstat command - */ - if (printer != NULL) { - if (strcasecmp(pname, printer) != 0) { - /* - * Read the job-printer-uri as - * it will be different for - * different printers - */ - uri = NULL; - (void) papiAttributeListGetString(attrs, - NULL, "job-printer-uri", &uri); - pname = printer; - if (uri != NULL) - puri = strdup(uri); - else - puri = NULL; - } else { - /* - * Same printer queried twice - * uri should be the same as - * already read in the previous call - * to 'report_job'. - * For the same printer 'job-printer-uri' - * is read just once because only in the - * first call it contains the host information - */ - uri = puri; - } - } - } - - if (host) { - /* Check if it is local printer or remote printer */ - uri_t *u = NULL; - - if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { - char *nodename = localhostname(); - - if ((u->host == NULL) || - (strcasecmp(u->host, "localhost") == 0) || - (strcasecmp(u->host, nodename) == 0)) { - - if (strcasecmp(host, nodename) == 0) { - /* - * Request submitted locally - * for the local queue. - * Hostname will not be displayed - */ - snprintf(User, sizeof (User), "%s", - user); - } - else - snprintf(User, sizeof (User), "%s@%s", - user, host); - } else if (uri != NULL) { - /* - * It's a remote printer. - * In case of remote printers hostname is - * always displayed. - */ - snprintf(User, sizeof (User), "%s@%s", - user, host); - } - uri_free(u); - } else { - /* - * If attribute "job-printer-uri" - * cannot be read - * by default append the hostname - */ - snprintf(User, sizeof (User), "%s@%s", user, host); - } - } else { - /* - * When print server is s10u4 and ipp service is used - * "job-originating-hostname" attribute is not set - * So get the host information from the uri - */ - uri_t *u = NULL; - if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { - if ((u != NULL) && (u->host != NULL)) - snprintf(User, sizeof (User), "%s@%s", - user, u->host); - else - snprintf(User, sizeof (User), "%s", user); - - uri_free(u); - } else - snprintf(User, sizeof (User), "%s", user); - } - (void) papiAttributeListGetInteger(attrs, NULL, "job-k-octets", &size); - size *= 1024; /* for the approximate byte size */ - (void) papiAttributeListGetInteger(attrs, NULL, "job-octets", &size); - - (void) time(&clock); - (void) papiAttributeListGetInteger(attrs, NULL, - "time-at-creation", (int32_t *)&clock); - (void) strftime(date, sizeof (date), "%b %d %R", localtime(&clock)); - - (void) papiAttributeListGetString(attrs, NULL, - "job-printer-uri", &destination); - (void) papiAttributeListGetString(attrs, NULL, - "printer-name", &destination); - (void) papiAttributeListGetInteger(attrs, NULL, - "job-id", &id); - (void) papiAttributeListGetInteger(attrs, NULL, - "job-id-requested", &id); - - - snprintf(request, sizeof (request), "%s-%d", printer, id); - - if (show_rank != 0) { - int32_t rank = -1; - - (void) papiAttributeListGetInteger(attrs, NULL, - "number-of-intervening-jobs", &rank); - rank++; - - printf("%3d %-21s %-14s %7ld %s", - rank, request, User, size, date); - } else - printf("%-23s %-14s %7ld %s", request, User, size, date); - - (void) papiAttributeListGetInteger(attrs, NULL, - "job-state", &jstate); - - if (jstate == 0x0001) - printf(gettext(" being held")); - else if (jstate == 0x0800) - printf(gettext(" notifying user")); - else if (jstate == 0x0040) - printf(gettext(" cancelled")); - else if (jstate == 0x0010) - printf(gettext(" finished printing")); - else if (jstate == 0x0008) - printf(gettext(" on %s"), destination); - else if (jstate == 0x2000) - printf(gettext(" held by admin")); - else if (jstate == 0x0002) - printf(gettext(" being filtered")); - else if (jstate == 0x0004) - printf(gettext(" filtered")); - else if (jstate == 0x0020) - printf(gettext(" held for change")); - - if (verbose == 1) { - char *form = NULL; - - (void) papiAttributeListGetString(attrs, NULL, - "output-device-assigned", &destination); - printf("\n\t assigned %s", destination); - - (void) papiAttributeListGetString(attrs, NULL, "form", &form); - if (form != NULL) - printf(", form %s", form); - } else if (verbose > 1) { - printf("\n"); - papiAttributeListPrint(stdout, attrs, "\t"); - } - - printf("\n"); - - return (0); -} - -static int -job_query(char *request, int (*report)(char *, papi_job_t, int, int), - papi_encryption_t encryption, int show_rank, int verbose) -{ - int result = 0; - papi_status_t status; - papi_service_t svc = NULL; - char *printer = request; - int32_t id = -1; - int flag1 = 0; - int flag = 1; - int print_flag = 0; - - do { - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - - if ((status == PAPI_OK) && (printer != NULL)) - print_flag = 1; - - /* <name>-# printer name does not exist */ - if (status != PAPI_OK) { - /* - * Check if <name>-# is a request-id - * Once this check is done flag1 is set - */ - if (flag1 == 1) - break; - - get_printer_id(printer, &printer, &id); - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - (printer ? printer : "all"), - verbose_papi_message(svc, status)); - return (-1); - } - } - - if (printer == NULL) { /* all */ - char **interest = interest_list(svc); - - if (interest != NULL) { - int i; - - for (i = 0; interest[i] != NULL; i++) - result += job_query(interest[i], report, - encryption, show_rank, verbose); - } - } else if (id == -1) { /* a printer */ - papi_job_t *jobs = NULL; - - status = papiPrinterListJobs(svc, printer, NULL, - 0, 0, &jobs); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to get job list: %s\n"), - verbose_papi_message(svc, status)); - papiServiceDestroy(svc); - return (-1); - } - - if (jobs != NULL) { - int i; - - for (i = 0; jobs[i] != NULL; i++) - result += report(printer, - jobs[i], show_rank, - verbose); - } - - papiJobListFree(jobs); - } else { /* a job */ - papi_job_t job = NULL; - - /* Once a job has been found stop processing */ - flag = 0; - - /* - * Job-id could be the job-id requested - * Check if it is job-id or job-id-requested - */ - id = job_to_be_queried(svc, printer, id); - - if (id >= 0) - status = papiJobQuery(svc, printer, id, - NULL, &job); - else - /* id not found */ - status = PAPI_NOT_FOUND; - - if (status != PAPI_OK) { - if (!print_flag) - fprintf(stderr, gettext( - "Failed to get job"\ - " info for %s: %s\n"), - request, - verbose_papi_message(svc, status)); - papiServiceDestroy(svc); - return (-1); - } - - if (job != NULL) - result = report(printer, job, - show_rank, verbose); - - papiJobFree(job); - } - - if (flag) { - id = -1; - get_printer_id(printer, &printer, &id); - if (id == -1) - flag = 0; - else - flag1 = 1; - } - } while (flag); - - papiServiceDestroy(svc); - - return (result); -} - -static int -report_form(char *name, papi_attribute_t **attrs, int verbose) -{ - papi_status_t status; - char *form = NULL; - void *iter = NULL; - - for (status = papiAttributeListGetString(attrs, &iter, - "form-supported", &form); - status == PAPI_OK; - status = papiAttributeListGetString(attrs, &iter, - NULL, &form)) { - if ((name == NULL) || (strcmp(name, form) == 0)) { - printf(gettext("form %s is available to you\n"), form); - if (verbose != 0) { - char *detail = NULL; - status = papiAttributeListGetString(attrs, NULL, - "form-supported-detail", &detail); - if (status == PAPI_OK) - printf("%s\n", detail); - } - } - } - - return (0); -} - -static int -report_print_wheels(char *name, papi_attribute_t **attrs, int verbose) -{ - papi_status_t status; - char *pw = NULL; - void *iter = NULL; - - for (status = papiAttributeListGetString(attrs, &iter, - "pw-supported", &pw); - status == PAPI_OK; - status = papiAttributeListGetString(attrs, &iter, NULL, &pw)) { - if ((name == NULL) || (strcmp(name, pw) == 0)) { - printf(gettext("charset %s is available\n"), pw); - if (verbose != 0) { - char *info = NULL; - status = papiAttributeListGetString(attrs, NULL, - "pw-supported-extra", &info); - if (status == PAPI_OK) - printf("%s\n", info); - } - } - } - - return (0); -} - -static int -service_query(char *name, int (*report)(char *, papi_attribute_t **, int), - papi_encryption_t encryption, int verbose) -{ - int result = 0; - papi_status_t status; - papi_service_t svc = NULL; - papi_attribute_t **attrs = NULL; - - status = papiServiceCreate(&svc, name, NULL, NULL, cli_auth_callback, - encryption, NULL); - if (status != PAPI_OK) { - papiServiceDestroy(svc); - return (-1); - } - - attrs = papiServiceGetAttributeList(svc); - if (attrs != NULL) { - result = report(name, attrs, verbose); - - if (verbose > 1) { - printf("\n"); - papiAttributeListPrint(stdout, attrs, "\t"); - printf("\n"); - } - } - - papiServiceDestroy(svc); - - return (result); -} - -int -main(int ac, char *av[]) -{ - int exit_code = 0; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - int rank = 0; - int verbose = 0; - int description = 0; - int c; - char **argv; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - argv = (char **)calloc((ac + 1), sizeof (char *)); - for (c = 0; c < ac; c++) { - if ((av[c][0] == '-') && (av[c][1] == 'l') && - (isalpha(av[c][2]) != 0)) { - /* preserve old "-l[po...]" behavior */ - argv[c] = &av[c][1]; - argv[c][0] = '-'; - verbose = 1; - - } else - argv[c] = av[c]; - } - - argv[c++] = "--"; - ac = c; - - /* preprocess argument list looking for '-l' or '-R' so it can trail */ - while ((c = getopt(ac, argv, "LEDf:S:stc:p:a:drs:v:l:o:R:u:")) != EOF) { - switch (c) { /* these may or may not have an option */ - case 'a': - case 'c': - case 'p': - case 'o': - case 'R': - case 'u': - case 'v': - case 'l': - case 'f': - case 'S': - if (optarg[0] == '-') { - /* this check stop a possible infinite loop */ - if ((optind > 1) && (argv[optind-1][1] != c)) - optind--; - optarg = NULL; - } else if (strcmp(optarg, "all") == 0) - optarg = NULL; - } - - switch (c) { - case 'l': - if ((optarg == NULL) || (optarg[0] == '-')) - optarg = "1"; - verbose = atoi(optarg); - break; - case 'D': - description = 1; - break; - case 'R': - rank = 1; - break; - case 'E': - encryption = PAPI_ENCRYPT_REQUIRED; - break; - default: - break; - } - } - optind = 1; - - /* process command line arguments */ - while ((c = getopt(ac, argv, "LEDf:S:stc:p:a:drs:v:l:o:R:u:")) != EOF) { - switch (c) { /* these may or may not have an option */ - case 'a': - case 'c': - case 'p': - case 'o': - case 'R': - case 'u': - case 'v': - case 'l': - case 'f': - case 'S': - if (optarg[0] == '-') { - /* this check stop a possible infinite loop */ - if ((optind > 1) && (argv[optind-1][1] != c)) - optind--; - optarg = NULL; - } else if (strcmp(optarg, "all") == 0) - optarg = NULL; - } - - switch (c) { - case 'a': - exit_code += printer_query(optarg, report_accepting, - encryption, verbose, 0); - break; - case 'c': - exit_code += printer_query(optarg, report_class, - encryption, verbose, 0); - break; - case 'p': - exit_code += printer_query(optarg, report_printer, - encryption, verbose, description); - break; - case 'd': - exit_code += lpstat_default_printer(encryption); - break; - case 'r': - exit_code += lpstat_service_status(encryption); - break; - case 'u': - if (optarg != NULL) - users = strsplit(optarg, ", \n"); - exit_code += job_query(NULL, report_job, - encryption, rank, verbose); - if (users != NULL) { - free(users); - users = NULL; - } - break; - case 'v': - exit_code += printer_query(optarg, report_device, - encryption, verbose, 0); - break; - case 'R': /* set "rank" flag in first pass */ - case 'o': - exit_code += job_query(optarg, report_job, - encryption, rank, verbose); - break; - case 'f': - exit_code += service_query(optarg, report_form, - encryption, verbose); - break; - case 'S': - exit_code += service_query(optarg, report_print_wheels, - encryption, verbose); - break; - case 's': - exit_code += lpstat_service_status(encryption); - exit_code += lpstat_default_printer(encryption); - exit_code += printer_query(NULL, report_class, - encryption, verbose, 0); - exit_code += printer_query(NULL, report_device, - encryption, verbose, 0); - exit_code += service_query(optarg, report_form, - encryption, verbose); - exit_code += service_query(optarg, report_print_wheels, - encryption, verbose); - break; - case 't': - exit_code += lpstat_service_status(encryption); - exit_code += lpstat_default_printer(encryption); - exit_code += printer_query(NULL, report_class, - encryption, verbose, 0); - exit_code += printer_query(NULL, report_device, - encryption, verbose, 0); - exit_code += printer_query(NULL, report_accepting, - encryption, verbose, 0); - exit_code += printer_query(NULL, report_printer, - encryption, verbose, 0); - exit_code += service_query(optarg, report_form, - encryption, verbose); - exit_code += service_query(optarg, report_print_wheels, - encryption, verbose); - exit_code += job_query(NULL, report_job, - encryption, rank, verbose); - break; - case 'L': /* local-only, ignored */ - case 'l': /* increased verbose level in first pass */ - case 'D': /* set "description" flag in first pass */ - case 'E': /* set encryption in the first pass */ - break; - default: - usage(av[0]); - } - } - ac--; - - if (ac == 1) { /* report on my jobs */ - struct passwd *pw = getpwuid(getuid()); - - if (pw != NULL) - users = strsplit(pw->pw_name, ""); - exit_code += job_query(NULL, report_job, encryption, - rank, verbose); - if (users != NULL) { - free(users); - users = NULL; - } - } else { - for (c = optind; c < ac; c++) - exit_code += job_query(argv[c], report_job, encryption, - rank, verbose); - } - - - if (exit_code != 0) - exit_code = 1; - - return (exit_code); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/reject.c b/usr/src/cmd/print/bsd-sysv-commands/reject.c deleted file mode 100644 index 2952bafba6..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/reject.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -/* $Id: reject.c 146 2006-03-24 00:26:54Z njacobs $ */ - - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <locale.h> -#include <libintl.h> -#include <papi.h> -#include "common.h" - -static void -usage(char *program) -{ - char *name; - - if ((name = strrchr(program, '/')) == NULL) - name = program; - else - name++; - - fprintf(stdout, - gettext("Usage: %s destination ...\n"), - name); - exit(1); -} - -int -main(int ac, char *av[]) -{ - papi_status_t status; - papi_service_t svc = NULL; - papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; - char *reason = NULL; - int exit_status = 0; - int c = 1; - - (void) setlocale(LC_ALL, ""); - (void) textdomain("SUNW_OST_OSCMD"); - - while ((c = getopt(ac, av, "Er:")) != EOF) - switch (c) { - case 'r': /* reason */ - reason = optarg; - break; - case 'E': - encryption = PAPI_ENCRYPT_ALWAYS; - break; - default: - usage(av[0]); - } - - if (ac <= optind) - usage(av[0]); - - while (optind < ac) { - char *printer = av[optind++]; - - status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); - if (status != PAPI_OK) { - fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); - exit_status = 1; - } - - status = papiPrinterPause(svc, printer, reason); - if (status == PAPI_OK) { - printf(gettext( - "Destination \"%s\" will no longer " - "accept requests\n"), printer); - } else if (status == PAPI_NOT_ACCEPTING) { - fprintf(stderr, gettext( - "Destination \"%s\" was already not " - "accepting requests.\n"), printer); - exit_status = 1; - } else { - /* The operation is not supported in lpd protocol */ - if (status == PAPI_OPERATION_NOT_SUPPORTED) { - fprintf(stderr, - verbose_papi_message(svc, status)); - } else { - fprintf(stderr, gettext("reject: %s: %s\n"), - printer, verbose_papi_message(svc, status)); - } - exit_status = 1; - } - - papiServiceDestroy(svc); - } - - return (exit_status); -} diff --git a/usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml b/usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml deleted file mode 100644 index b6783bca28..0000000000 --- a/usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml +++ /dev/null @@ -1,110 +0,0 @@ -<?xml version='1.0'?> -<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> - -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - - Copyright 2009 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - NOTE: This service manifest is not editable; its contents will - be overwritten by package or patch operations, including - operating system upgrade. Make customizations in a different - file. ---> - -<service_bundle type='manifest' name='SUNWpsr:rfc1179'> - -<service - name='application/print/rfc1179' - type='service' - version='1'> - - <create_default_instance enabled='false' /> - - <restarter> - <service_fmri value='svc:/network/inetd:default' /> - </restarter> - - <dependency - name='lpsched' - grouping='require_all' - restart_on='refresh' - type='service'> - <service_fmri value='svc:/application/print/server' /> - </dependency> - - <exec_method - type='method' - name='inetd_start' - exec='/usr/lib/print/in.lpd -u lp -d /var/run/in.lpd' - timeout_seconds='0'> - <method_context> - <method_credential user='root' group='lp' /> - </method_context> - </exec_method> - - - <exec_method - type='method' - name='inetd_disable' - exec=':kill' - timeout_seconds='0'> - </exec_method> - - <property_group name='inetd' type='framework'> - <stability value='Evolving' /> - <propval name='endpoint_type' type='astring' value='stream' /> - <propval name='name' type='astring' value='printer' /> - <propval name='wait' type='boolean' value='false' /> - <propval name='isrpc' type='boolean' value='false' /> - <propval name='proto' type='astring' value='tcp6' /> - </property_group> - - <property_group name='general' type='framework'> - <!-- to start/stop rfc1179 listening --> - <propval name='action_authorization' type='astring' - value='solaris.print.admin' /> - <propval name='value_authorization' type='astring' - value='solaris.print.admin' /> - </property_group> - - <property_group name='firewall_context' type='com.sun,fw_definition'> - <propval name='ipf_method' type='astring' - value='/lib/svc/method/print-svc ipfilter svc:/application/print/server:default' /> - </property_group> - - <stability value='Unstable' /> - - <template> - <common_name> - <loctext xml:lang='C'> - BSD print protocol adapter - </loctext> - </common_name> - <documentation> - <manpage title='in.lpd' section='1M' - manpath='/usr/share/man' /> - </documentation> - </template> - -</service> - -</service_bundle> diff --git a/usr/src/cmd/print/conv_fix/Makefile b/usr/src/cmd/print/conv_fix/Makefile deleted file mode 100644 index cac80619e0..0000000000 --- a/usr/src/cmd/print/conv_fix/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/client/conv_fix/Makefile -# - -include ../Makefile.sp - -PROG= conv_fix - -SRCS= $(PROG).c - -OBJS= $(SRCS:.c=.o) - -ROOTLIBPRINTPROG= $(PROG:%=$(ROOTLIBPRINT)/%) - -FILEMODE= 0555 - -CPPFLAGS += -I$(NPRTINC) - -CERRWARN += -_gcc=-Wno-implicit-function-declaration - -.KEEP_STATE: - -all: $(PROG) - -install: all $(ROOTLIBPRINTPROG) - -$(ROOTLIBPRINT)/%: % - $(INS.file) - -strip: - $(STRIP) $(PROG) - -lint: - $(LINT.c) $(PROG).c $(LDLIBS) - -cstyle: - cstyle $(SRCS) - -_msg: - @echo "Messages are made in usr/src/cmd/print" - -clean: - $(RM) $(OBJS) - -clobber: clean - -$(RM) $(PROG) $(CLOBBERFILES) diff --git a/usr/src/cmd/print/conv_fix/conv_fix.c b/usr/src/cmd/print/conv_fix/conv_fix.c deleted file mode 100644 index 2833b106bb..0000000000 --- a/usr/src/cmd/print/conv_fix/conv_fix.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <locale.h> -#include <sys/file.h> -#include <fcntl.h> -#include <errno.h> - -extern char *optarg; - -/* - * FUNCTION: - * static char *_file_getline(FILE *fp) - * INPUT: - * FILE *fp - file pointer to read from - * OUTPUT: - * char *(return) - an entry from the stream - * DESCRIPTION: - * This routine will read in a line at a time. If the line ends in a - * newline, it returns. If the line ends in a backslash newline, it - * continues reading more. It will ignore lines that start in # or - * blank lines. - */ -static char * -_file_getline(FILE *fp) -{ - char entry[BUFSIZ], *tmp; - int size; - - size = sizeof (entry); - tmp = entry; - - /* find an entry */ - while (fgets(tmp, size, fp)) { - if ((tmp == entry) && ((*tmp == '#') || (*tmp == '\n'))) { - continue; - } else { - if ((*tmp == '#') || (*tmp == '\n')) { - *tmp = NULL; - break; - } - - size -= strlen(tmp); - tmp += strlen(tmp); - - if (*(tmp-2) != '\\') - break; - - size -= 2; - tmp -= 2; - } - } - - if (tmp == entry) - return (NULL); - else - return (strdup(entry)); -} - -int -main(int ac, char *av[]) -{ - int c; - char file[80], ofile[80]; - char *cp; - FILE *fp, *fp2; - - (void) setlocale(LC_ALL, ""); - -#if !defined(TEXT_DOMAIN) -#define TEXT_DOMAIN "SYS_TEST" -#endif - (void) textdomain(TEXT_DOMAIN); - - while ((c = getopt(ac, av, "f:o:")) != EOF) - - switch (c) { - case 'f': - (void) strlcpy(file, optarg, sizeof (file)); - break; - case 'o': - (void) strlcpy(ofile, optarg, sizeof (ofile)); - break; - default: - (void) fprintf(stderr, gettext( - "Usage: %s [-f file] [-o output file]\n"), - av[0]); - return (1); - } - - if ((fp = fopen(file, "r")) != NULL) { - int fd; - - fd = open(ofile, O_RDWR|O_APPEND); - if ((fd < 0) && (errno == ENOENT)) - fd = open(ofile, O_RDWR|O_CREAT|O_EXCL, 0644); - - if (fd < 0) { - (void) fprintf(stderr, - gettext("Error trying to open file.\n")); - return (1); - } - - lseek(fd, 0, SEEK_END); - - if ((fp2 = fdopen(fd, "a")) != NULL) { - while ((cp = _file_getline(fp)) != NULL) { - (void) fprintf(fp2, "%s", cp); - } - return (0); - } else { - (void) fprintf(stderr, - gettext("Error trying to open file.\n")); - return (1); - } - } else { - (void) fprintf(stderr, - gettext("Error trying to open file.\n")); - return (1); - } -} diff --git a/usr/src/cmd/print/lpget/Makefile b/usr/src/cmd/print/lpget/Makefile deleted file mode 100644 index db4d15b2b1..0000000000 --- a/usr/src/cmd/print/lpget/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/client/lpget/Makefile -# - -include ../Makefile.sp - -PROG= lpget - -SRCS= $(PROG).c - -OBJS= $(SRCS:.c=.o) - -ROOTBINPROG= $(PROG:%=$(ROOTBIN)/%) - -FILEMODE= 0511 - -CPPFLAGS += -I$(NPRTINC) -LDLIBS += $(LIBNPRT) - -.KEEP_STATE: - -all: $(PROG) - -install: all $(ROOTBIN) $(ROOTBINPROG) - -$(ROOTBIN): - $(INS.dir) - -strip: - $(STRIP) $(PROG) - -lint: - $(LINT.c) $(PROG).c $(LDLIBS) - -cstyle: - cstyle $(SRCS) - -_msg: - @echo "Messages are made in usr/src/cmd/print" - -clean: - $(RM) $(OBJS) - -clobber: clean - -$(RM) $(PROG) $(CLOBBERFILES) diff --git a/usr/src/cmd/print/lpget/lpget.c b/usr/src/cmd/print/lpget/lpget.c deleted file mode 100644 index 5c19480ae1..0000000000 --- a/usr/src/cmd/print/lpget/lpget.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <stdarg.h> -#include <unistd.h> -#include <string.h> -#include <syslog.h> -#include <locale.h> -#ifndef SUNOS_4 -#include <libintl.h> -#endif - -#include <ns.h> -#include <list.h> - -extern char *optarg; -extern int optind, opterr, optopt; -extern char *getenv(const char *); - - -static void -Usage(char *name) -{ - (void) fprintf(stderr, - gettext("Usage: %s [-k key] [list|(printer) ...]\n"), - name); - exit(1); -} - -static int -display_kvp(char *key, char *value) -{ - int rc = -1; - - if (value != NULL) { - rc = 0; - (void) printf("\n\t%s=%s", key, value); - } else - (void) printf(gettext("\n\t%s - undefined"), key); - - return (rc); -} - - -static int -display_value(ns_printer_t *printer, char *name, char **keys) -{ - int rc = -1; - - if (printer != NULL) { - rc = 0; - (void) printf("%s:", name); - if (keys != NULL) { - while (*keys != NULL) { - char *string = ns_get_value_string(*keys, - printer); - rc += display_kvp(*keys, string); - keys++; - } - } else { - ns_kvp_t **list = printer->attributes; - - for (list = printer->attributes; - (list != NULL && *list != NULL); list++) { - char *string; - if (((*list)->key[0] == '\t') || - ((*list)->key[0] == ' ')) - continue; - - string = ns_get_value_string((*list)->key, - printer); - rc += display_kvp((*list)->key, string); - } - } - (void) printf("\n"); - } else - (void) printf(gettext("%s: Not Found\n"), name); - - return (rc); -} - - -/* - * main() calls the appropriate routine to parse the command line arguments - * and then calls the local remove routine, followed by the remote remove - * routine to remove jobs. - */ -int -main(int ac, char *av[]) -{ - char *program; - int c; - char **keys = NULL; - char *ns = NULL; - int exit_code = 0; - - (void) setlocale(LC_ALL, ""); - -#if !defined(TEXT_DOMAIN) -#define TEXT_DOMAIN "SYS_TEST" -#endif - (void) textdomain(TEXT_DOMAIN); - - if ((program = strrchr(av[0], '/')) == NULL) - program = av[0]; - else - program++; - - openlog(program, LOG_PID, LOG_LPR); - while ((c = getopt(ac, av, "k:t:n:")) != EOF) - switch (c) { - case 'k': - case 't': - keys = (char **)list_append((void **)keys, - (void *)optarg); - break; - case 'n': - ns = optarg; - break; - default: - Usage(program); - } - - if (optind >= ac) - Usage(program); - - ns = normalize_ns_name(ns); - - while (optind < ac) { - char *name = av[optind++]; - - if (strcmp(name, "list") == 0) { - ns_printer_t **printers = ns_printer_get_list(ns); - - while (printers != NULL && *printers != NULL) { - exit_code += display_value(*printers, - (*printers)->name, keys); - printers++; - } - } else - exit_code = display_value(ns_printer_get_name(name, ns), - name, keys); - - - } - return (exit_code); -} diff --git a/usr/src/cmd/print/lpset/Makefile b/usr/src/cmd/print/lpset/Makefile deleted file mode 100644 index 7b81c117b2..0000000000 --- a/usr/src/cmd/print/lpset/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/client/lpset/Makefile -# - -include ../Makefile.sp - -PROG= lpset - -SRCS= $(PROG).c - -OBJS= $(SRCS:.c=.o) - -ROOTBINPROG= $(PROG:%=$(ROOTBIN)/%) - -FILEMODE= 04511 - -CPPFLAGS += -I$(NPRTINC) -CERRWARN += -_gcc=-Wno-implicit-function-declaration -LDLIBS += $(LIBNPRT) -lsecdb - -.KEEP_STATE: - -all: $(PROG) - -install: all $(ROOTBIN) $(ROOTBINPROG) - -$(ROOTBIN): - $(INS.dir) - -strip: - $(STRIP) $(PROG) - -lint: - $(LINT.c) $(PROG).c $(LDLIBS) - -cstyle: - cstyle $(SRCS) - -_msg: - @echo "Messages are made in usr/src/cmd/print" - -clean: - $(RM) $(OBJS) - -clobber: clean - -$(RM) $(PROG) $(CLOBBERFILES) diff --git a/usr/src/cmd/print/lpset/lpset.c b/usr/src/cmd/print/lpset/lpset.c deleted file mode 100644 index 6cb6b05a8a..0000000000 --- a/usr/src/cmd/print/lpset/lpset.c +++ /dev/null @@ -1,544 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <stdarg.h> -#include <unistd.h> -#include <limits.h> -#include <string.h> -#include <syslog.h> -#include <errno.h> -#include <locale.h> -#ifndef SUNOS_4 -#include <libintl.h> -#endif -#include <pwd.h> -#include <alloca.h> - -#include <ns.h> -#include <list.h> - -extern char *optarg; -extern int optind, opterr, optopt; -extern char *getenv(const char *); - -static void _decode_ldapResult(int result, char *printerName); - -static int -authorized() -{ - struct passwd *pw; - uid_t uid; - gid_t *list; - int len; - int maxgrp; - - if ((uid = getuid()) == 0) - return (1); /* "root" is authorized */ - - if (((pw = getpwnam("lp")) != NULL) && (uid == pw->pw_uid)) - return (1); /* "lp" is authorized */ - - if ((pw = getpwuid(uid)) == NULL) - return (0); /* intruders are not authorized */ - - if (chkauthattr("solaris.print.admin", pw->pw_name) == 1) - return (1); /* "solaris.print.admin" is authorized */ - - /* How many supplemental groups do we have? */ - maxgrp = getgroups(0, NULL); - list = alloca(maxgrp * sizeof (gid_t)); - - if ((len = getgroups(maxgrp, list)) != -1) - while (len-- > 0) - if (list[len] == 14) - return (1); /* group 14 is authorized */ - - return (0); /* nobody else is authorized */ -} - -static void -Usage(char *name) -{ - (void) fprintf(stderr, - gettext("Usage: %s [-n files | ldap] [-x] " - "[-h ldaphost] [-D binddn] [-w passwd] " - "[-a key=value] [-d key] (printer)\n"), - name); - exit(1); -} - - -/* - * main() calls the appropriate routine to parse the command line arguments - * and then calls the local remove routine, followed by the remote remove - * routine to remove jobs. - */ -int -main(int ac, char *av[]) -{ - int result = 0; - int delete_printer = 0; - int c; - char *program = NULL, - *printer = NULL, - *host = NULL, - *binddn = NULL, - *passwd = NULL, - *ins = NULL, - *ons = "files"; - char **changes = NULL; - ns_cred_t *cred = NULL; - ns_printer_t *printer_obj = NULL; - - (void) setlocale(LC_ALL, ""); - -#if !defined(TEXT_DOMAIN) -#define TEXT_DOMAIN "SYS_TEST" -#endif - (void) textdomain(TEXT_DOMAIN); - - if ((program = strrchr(av[0], '/')) == NULL) - program = av[0]; - else - program++; - - openlog(program, LOG_PID, LOG_LPR); - - if (ac < 2) - Usage(program); - - while ((c = getopt(ac, av, "a:d:D:h:n:r:w:x")) != EOF) - switch (c) { - case 'd': - if (strchr(optarg, '=') != NULL) - Usage(program); - /* FALLTHRU */ - case 'a': - changes = (char **)list_append((void**)changes, - (void *)strdup(optarg)); - break; - case 'D': - binddn = optarg; - break; - case 'h': - host = optarg; - break; - case 'n': - ons = optarg; - break; - case 'r': - ins = optarg; - break; - case 'w': - passwd = optarg; - break; - case 'x': - delete_printer++; - break; - default: - Usage(program); - } - - if (optind != ac-1) - Usage(program); - - /* - * Check required options have been given: [ -x | [ -a | -d ]] - */ - if ((changes == NULL) && (delete_printer == 0)) { - Usage(program); - } - - printer = av[optind]; - - if (strchr(printer, ':') != NULL) { - (void) fprintf(stderr, gettext( - "POSIX-Style names are not valid destinations (%s)\n"), - printer); - return (1); - } - - ins = normalize_ns_name(ins); - ons = normalize_ns_name(ons); - if (ins == NULL) - ins = ons; - - /* check / set the name service for writing */ - if (strcasecmp("user", ons) == 0) { - (void) setuid(getuid()); - ons = "user"; - } else if (strcasecmp("files", ons) == 0) { - if (authorized() == 0) { - (void) fprintf(stderr, gettext( - "Permission denied: not authorized\n")); - return (1); - } - ons = "files"; - } else if (strcasecmp("ldap", ons) == 0) { - if ((cred = calloc(1, sizeof (*cred))) == NULL) { - (void) fprintf(stderr, - gettext("could not initialize credential\n")); - return (1); - } - - if (binddn == NULL) { - (void) fprintf(stderr, - gettext("Distinguished Name is required.\n")); - return (1); - } - - if (passwd == NULL) { - passwd = getpassphrase(gettext("Bind Password:")); - } - - /* - * Setup LDAP bind credentials, so that it uses - * the default ldap port, and the NS domain for this - * ldapclient box. Note: passwdType is currently not - * used but once the ldap native function can select - * secure or insure password it will pass the user selected - * security type. - */ - cred->passwd = passwd; - cred->passwdType = NS_PW_INSECURE; /* use default */ - cred->binddn = binddn; - cred->host = host; - cred->port = 0; /* use default */ - cred->domainDN = NULL; /* use default */ - - ons = "ldap"; - (void) setuid(getuid()); - } else { - (void) fprintf(stderr, - gettext("%s is not a supported name service.\n"), - ons); - return (1); - } - - if (strcasecmp(NS_SVC_LDAP, ons) != 0) { - - /* Naming Service is not LDAP */ - - /* get the printer object */ - if ((printer_obj = ns_printer_get_name(printer, ins)) == NULL) { - if (delete_printer != 0) { - (void) fprintf(stderr, gettext - ("%s: unknown printer\n"), printer); - return (1); - } - if ((printer_obj = calloc(1, sizeof (*printer_obj))) - == NULL) { - (void) fprintf(stderr, gettext( - "could not initialize printer object\n")); - return (1); - } - printer_obj->name = strdup(printer); - } - - printer_obj->source = ons; - - if (cred != NULL) { - printer_obj->cred = cred; - } - - /* make the changes to it */ - while (changes != NULL && *changes != NULL) { - int has_equals = (strchr(*changes, '=') != NULL); - char *p, *key = NULL, *value = NULL; - - key = *(changes++); - - for (p = key; ((p != NULL) && (*p != NULL)); p++) - if (*p == '=') { - *p = NULL; - value = ++p; - break; - } else if (*p == '\\') - p++; - - if ((value != NULL) && (*value == NULL)) - value = NULL; - - if ((key != NULL) && (key[0] != NULL)) { - if ((value == NULL) && - (ns_get_value(key, printer_obj) == NULL) && - (has_equals == 0)) { - fprintf(stderr, - gettext("%s: unknown attribute\n"), - key); - result = 1; - } else - (void) ns_set_value_from_string(key, value, - printer_obj); - } - } - if (delete_printer != 0) - printer_obj->attributes = NULL; - - /* write it back */ - if (ns_printer_put(printer_obj) != 0) { - (void) fprintf(stderr, - gettext("Failed to write into %s database\n"), - ons); - result = 1; - } - } - - else { - /* - * Naming Service is LDAP - * - * Action the request by calling ns ldap functions to - * add, modify or delete the printer object. - */ - - if ((printer_obj = calloc(1, sizeof (*printer_obj))) == NULL) { - (void) fprintf(stderr, gettext( - "could not initialize printer object\n")); - return (1); - } - - if ((cred != NULL) && (printer_obj != NULL)) { - printer_obj->name = strdup(printer); - printer_obj->cred = cred; - printer_obj->cred->domainDN = NULL; /* use default */ - printer_obj->source = ons; - printer_obj->nsdata = malloc(sizeof (NS_LDAPDATA)); - - if (printer_obj->nsdata != NULL) { - /* - * Update the LDAP directory for this printer - */ - - if (delete_printer != 0) { - /* Delete the printer object */ - ((NS_LDAPDATA *) - (printer_obj->nsdata))->attrList - = NULL; - } else { - /* Add or modify the printer object */ - ((NS_LDAPDATA *) - (printer_obj->nsdata))->attrList = - changes; - } - - result = ns_printer_put(printer_obj); - if (result != 0) { - /* display LDAP specific message */ - _decode_ldapResult(result, printer); - - (void) fprintf(stderr, gettext( - "Failed to update %s database\n"), ons); - result = 1; - } - - free(printer_obj->nsdata); - } - - else { - _decode_ldapResult(NSL_ERR_MEMORY, NULL); - result = 1; - } - } - - else { - result = 1; - (void) fprintf(stderr, - gettext("Error - no LDAP credentials\n")); - } - - if (printer_obj != NULL) { - if (printer_obj->name != NULL) { - free(printer_obj->name); - } - free(printer_obj); - } - - } - - return (result); -} /* main */ - - - - -/* - * ***************************************************************************** - * - * Function: _decode_ldapResult() - * - * Description: Decode the ldap_put_printer specific error codes and display - * the appropriate error message. - * - * Parameters: - * Input: int result - contains the NSL_RESULT codes - * char *printerName - name of printer - * Output: None - * - * Returns: void - * - * ***************************************************************************** - */ - -static void -_decode_ldapResult(int result, char *printerName) - -{ - NSL_RESULT lresult = (NSL_RESULT)result; - - /* ------------- */ - - switch (lresult) - { - case NSL_OK: - { - break; - } - - case NSL_ERR_INTERNAL: - { - (void) fprintf(stderr, - gettext("Unexpected software error\n")); - break; - } - - case NSL_ERR_ADD_FAILED: - { - (void) fprintf(stderr, "%s %s\n", - gettext("Failed to add printer:"), printerName); - break; - } - - case NSL_ERR_MOD_FAILED: - { - (void) fprintf(stderr, "%s %s\n", - gettext("Failed to modify printer:"), - printerName); - break; - } - - case NSL_ERR_DEL_FAILED: - { - (void) fprintf(stderr, "%s %s\n", - gettext("Failed to delete printer:"), - printerName); - break; - } - - - case NSL_ERR_UNKNOWN_PRINTER: - { - (void) fprintf(stderr, "%s %s\n", - gettext("Unknown printer:"), printerName); - break; - } - - case NSL_ERR_CREDENTIALS: - { - (void) fprintf(stderr, "%s\n", - gettext("Missing LDAP credential information for printer:")); - break; - } - - case NSL_ERR_CONNECT: - { - (void) fprintf(stderr, "%s\n", - gettext("Failed to connect to LDAP server")); - break; - } - - case NSL_ERR_BIND: - { - (void) fprintf(stderr, gettext("LDAP bind failed\n")); - break; - } - - case NSL_ERR_RENAME: - { - (void) fprintf(stderr, "%s %s\n", - gettext("Object rename not allowed for printer:"), - printerName); - break; - } - - case NSL_ERR_KVP: - { - (void) fprintf(stderr, "%s", - gettext("Setting sun-printer-kvp attribute is " - "not supported through this command.\n")); - break; - } - - case NSL_ERR_BSDADDR: - { - (void) fprintf(stderr, "%s", - gettext("Setting sun-printer-bsdaddr attribute is " - "not supported through this command.\n" - "Use the bsaddr attribute instead.\n")); - break; - } - - case NSL_ERR_PNAME: - { - (void) fprintf(stderr, "%s", - gettext("Setting printer-name attribute is " - "not supported through this command.\n")); - break; - } - - case NSL_ERR_MEMORY: - { - (void) fprintf(stderr, - gettext("Memory allocation error\n")); - break; - } - - case NSL_ERR_MULTIOP: - { - (void) fprintf(stderr, - gettext("Delete and add operation on the " - "same key attribute is not allowed\n")); - break; - } - - case NSL_ERR_NOTALLOWED: - { - (void) fprintf(stderr, - gettext("KVP attribute is not allowed\n")); - break; - } - - default: - { - (void) fprintf(stderr, - gettext("Error code = %d\n"), result); - break; - } - } - -} /* _decode_ldapResult */ diff --git a/usr/src/cmd/print/ppdmgr/Makefile b/usr/src/cmd/print/ppdmgr/Makefile deleted file mode 100644 index ab8f07b46e..0000000000 --- a/usr/src/cmd/print/ppdmgr/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -MANIFEST= ppd-cache-update.xml -SVCMETHOD= ppd-cache-update - -include ../Makefile.sp - -ROOTMANIFESTDIR= $(ROOTSVCAPPLICATIONPRINT) -$(ROOTMANIFEST):= FILEMODE= 444 - -ROOTVARLP= $(ROOTVAR)/lp -ROOTVARLPPPD= $(ROOTVARLP)/ppd -ROOTVARLPPPDCACHES= $(ROOTVARLPPPD)/caches - -$(ROOTVARLP):= DIRMODE= 775 - -.KEEP_STATE: - -all: -install: $(ROOTMANIFEST) $(ROOTSVCMETHOD) \ - $(ROOTVARLP) $(ROOTVARLPPPD) $(ROOTVARLPPPDCACHES) -check: $(CHKMANIFEST) -clean: -clobber: -lint: - -$(ROOTVARLP) $(ROOTVARLPPPD) $(ROOTVARLPPPDCACHES): - $(INS.dir) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/cmd/print/ppdmgr/ppd-cache-update b/usr/src/cmd/print/ppdmgr/ppd-cache-update deleted file mode 100644 index 585f747c3f..0000000000 --- a/usr/src/cmd/print/ppdmgr/ppd-cache-update +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" - -. /lib/svc/share/smf_include.sh - -case "$1" in -'start') - if [ -x /usr/sbin/ppdmgr ] ; then - /usr/sbin/ppdmgr -u -R all -L all - fi - ;; -*) - echo "Usage: $0 start" - exit 1 - ;; -esac -exit $SMF_EXIT_OK diff --git a/usr/src/cmd/print/ppdmgr/ppd-cache-update.xml b/usr/src/cmd/print/ppdmgr/ppd-cache-update.xml deleted file mode 100644 index 67ade9b999..0000000000 --- a/usr/src/cmd/print/ppdmgr/ppd-cache-update.xml +++ /dev/null @@ -1,90 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 ---> -<!-- - Copyright 2007 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - ident "%Z%%M% %I% %E% SMI" - - NOTE: This service manifest is not editable; its contents will - be overwritten by package or patch operations, including - operating system upgrade. Make customizations in a different - file. ---> - -<service_bundle type='manifest' name='SUNWppm:ppd-cache-update'> - -<service - name='application/print/ppd-cache-update' - type='service' - version='1'> - - <create_default_instance enabled='false' /> - - <single_instance /> - - <!-- - This service writes to/reads from /tmp, /var, and /usr. - --> - <dependency - name='filesystem' - grouping='require_all' - restart_on='none' - type='service'> - <service_fmri value='svc:/system/filesystem/minimal' /> - </dependency> - - <exec_method - type='method' - name='start' - exec='/lib/svc/method/ppd-cache-update start' - timeout_seconds='0'> - </exec_method> - - <exec_method - type='method' - name='stop' - exec=':true' - timeout_seconds='3'> - </exec_method> - - <property_group name='startd' type='framework'> - <propval name='duration' type='astring' value='transient' /> - </property_group> - - <stability value='Unstable' /> - - <template> - <common_name> - <loctext xml:lang='C'> - ppd cache update - </loctext> - </common_name> - <documentation> - <manpage title='ppdmgr' section='1M' - manpath='/usr/share/man' /> - </documentation> - </template> -</service> - -</service_bundle> diff --git a/usr/src/cmd/print/printer-info/Makefile b/usr/src/cmd/print/printer-info/Makefile deleted file mode 100644 index 1aed6ba8f5..0000000000 --- a/usr/src/cmd/print/printer-info/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -include ../Makefile.sp - -ROOTLIBLPBIN = $(ROOTLIBLP)/bin - -PROG = printer-info -SRCS = $(PROG).c -OBJECTS = $(PROG).o - -ROOTPROG= $(PROG:%=$(ROOTLIBLPBIN)/%) -$(ROOTPROG) := FILEMODE=555 - -CERRWARN += -_gcc=-Wno-implicit-function-declaration - -.KEEP_STATE: - -all: $(PROG) - -$(ROOTLIBLPBIN): - $(INS.dir) - -$(ROOTLIBLPBIN)/%: % - $(INS.file) - -install: all $(ROOTLIBLPBIN) $(ROOTPROG) - -$(PROGRAM): $(OBJECTS) - $(CC) $(CFLAGS) -o $@ $(OBJECTS) - -clean: - $(RM) $(PROG) *.o - -cstyle: - cstyle $(SRCS) - -clobber: clean - -strip lint: - - - - - - diff --git a/usr/src/cmd/print/printer-info/printer-info.c b/usr/src/cmd/print/printer-info/printer-info.c deleted file mode 100644 index a469c5194d..0000000000 --- a/usr/src/cmd/print/printer-info/printer-info.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/prnio.h> -#include <fcntl.h> - -#define COMMAND_SET_MAX 16 /* more than 16 command sets is not likely */ -#define NP(x) (x ? x : "") - -typedef struct { - char *manufacturer; - char *model; - char *description; - char *class; - char *command_set[COMMAND_SET_MAX]; -} printer_description_t; - -int -get_printer_description(char *path, printer_description_t *info) -{ - int fd, rc; - struct prn_1284_device_id id; - char buf[BUFSIZ]; - char *s, *iter = NULL; - - /* open the device */ - if ((fd = open(path, O_RDWR)) < 0) - return (fd); - - /* get the 1284 device id */ - memset(&id, 0, sizeof (id)); - memset(&buf, 0, sizeof (buf)); - id.id_len = sizeof (buf); - id.id_data = buf; - - rc = ioctl(fd, PRNIOC_GET_1284_DEVID, &id); - /* close(fd); */ - if (rc < 0) - return (rc); - - memset(info, 0, sizeof (*info)); - - /* parse the 1284 device id string */ - for (s = (char *)strtok_r(buf, ";\n", &iter); s != NULL; - s = (char *)strtok_r(NULL, ";\n", &iter)) { - char *t, *u, *iter2 = NULL; - - if ((t = (char *)strtok_r(s, ":\n", &iter2)) == NULL) - continue; - - if ((u = (char *)strtok_r(NULL, ":\n", &iter2)) == NULL) - continue; - - if ((strcasecmp(t, "MFG") == 0) || - (strcasecmp(t, "MANUFACTURER") == 0)) - info->manufacturer = strdup(u); - else if ((strcasecmp(t, "MDL") == 0) || - (strcasecmp(t, "MODEL") == 0)) - info->model = strdup(u); - else if ((strcasecmp(t, "DES") == 0) || - (strcasecmp(t, "DESCRIPTION") == 0)) - info->description = strdup(u); - else if ((strcasecmp(t, "CLS") == 0) || - (strcasecmp(t, "CLASS") == 0)) - info->class = strdup(u); - else if ((strcasecmp(t, "CMD") == 0) || - (strcasecmp(t, "COMMAND SET") == 0)) { - /* this should be more dynamic, I got lazy */ - char *v, *iter3 = NULL; - int i = 0; - - for (v = (char *)strtok_r(u, ",\n", &iter3); - ((v != NULL) && (i < COMMAND_SET_MAX)); - v = (char *)strtok_r(NULL, ",\n", &iter3)) - info->command_set[i++] = strdup(v); - } - } - - return (0); -} - -static void -usage(char *name) -{ - char *program; - - if ((program = strrchr(name, '/')) == NULL) - program = name; - else - program++; - - printf("Usage: %s [-aMmdCc] (path) ...\n", program); -} - -int -main(int ac, char *av[]) -{ - int rc; - int manufacturer = 0, model = 0, description = 0, command_set = 0, - class = 0; - - while ((rc = getopt(ac, av, "aMmdCc")) != EOF) - switch (rc) { - case 'a': - manufacturer++; - model++; - description++; - command_set++; - class++; - break; - case 'M': - manufacturer++; - break; - case 'm': - model++; - break; - case 'd': - description++; - break; - case 'C': - command_set++; - break; - case 'c': - class++; - break; - default: - usage(av[0]); - exit(1); - } - - if (optind >= ac) { - usage(av[0]); - exit(1); - } - - while (optind < ac) { - char *path = av[optind++]; - printer_description_t info; - - rc = get_printer_description(path, &info); - if (rc == 0) { - printf("%s:\n", path); - if (manufacturer != 0) - printf("\tManufacturer: %s\n", - NP(info.manufacturer)); - if (model != 0) - printf("\tModel: %s\n", - NP(info.model)); - if (description != 0) - printf("\tDescription: %s\n", - NP(info.description)); - if (class != 0) - printf("\tClass: %s\n", - NP(info.class)); - if (command_set != 0) { - int i; - - printf("\tCommand set:\n"); - for (i = 0; info.command_set[i] != NULL; i++) - printf("\t\tcmd[%d]: %s\n", i, - info.command_set[i]); - } - } else - perror(path); - } - return (rc); -} diff --git a/usr/src/cmd/print/printmgr/Makefile b/usr/src/cmd/print/printmgr/Makefile deleted file mode 100644 index ef82fd7feb..0000000000 --- a/usr/src/cmd/print/printmgr/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Makefile for print manager -# -PROG = pmserver.jar pmclient.jar - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = com bin - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -ROOTDIRS = $(ROOT)/usr/sadm/admin \ - $(ROOT)/usr/sadm/admin/printmgr \ - $(ROOT)/usr/sadm/admin/printmgr/classes - -ROOTBIN = $(ROOT)/usr/sadm/admin/printmgr/classes -ROOTBINPROG = $(PROG:%=$(ROOTBIN)/%) - -$(ROOTBINPROG):= FILEMODE = 644 - -.KEEP_STATE: - -all: $(SUBDIRS) -install: $(SUBDIRS) $(ROOTDIRS) $(ROOTBINPROG) .WAIT links - -links: - $(RM) $(ROOTUSRSBIN)/printmgr - $(SYMLINK) ../../usr/sadm/admin/bin/printmgr \ - $(ROOTUSRSBIN)/printmgr - -clean clobber: $(SUBDIRS) - -$(RM) $(PROG) - -lint _msg: $(SUBDIRS) - -strip: - -$(PROG): FRC - @if [ $@ = "pmclient.jar" ]; \ - then $(JAR) cf $@ \ - com/sun/admin/pm/client/*class \ - com/sun/admin/pm/client/images/*gif 2>/dev/null; \ - else $(JAR) cf $@ \ - com/sun/admin/pm/server/*class 2>/dev/null; \ - fi - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -$(ROOTDIRS): - $(INS.dir) - -$(ROOTBIN)/%: % - $(INS.file) - -FRC: diff --git a/usr/src/cmd/print/printmgr/bin/Makefile b/usr/src/cmd/print/printmgr/bin/Makefile deleted file mode 100644 index 2964b6306f..0000000000 --- a/usr/src/cmd/print/printmgr/bin/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Makefile for print manager wrapper script -# -include $(SRC)/cmd/Makefile.cmd - -PROG = printmgr - -ROOTBIN = $(ROOT)/usr/sadm/admin/bin - -ROOTBINPROG = $(PROG:%=$(ROOTBIN)/%) - -ROOTDIRS = $(ROOT)/usr/sadm/admin \ - $(ROOT)/usr/sadm/admin/bin - -.KEEP_STATE: - -all: $(PROG) -install: all $(ROOTDIRS) $(ROOTBINPROG) - -$(ROOTBIN)/%: % - $(INS.file) - -$(ROOTDIRS): - $(INS.dir) - -lint strip _msg: - -clean clobber: - -$(RM) $(PROG) diff --git a/usr/src/cmd/print/printmgr/bin/printmgr.sh b/usr/src/cmd/print/printmgr/bin/printmgr.sh deleted file mode 100644 index c12d71cd86..0000000000 --- a/usr/src/cmd/print/printmgr/bin/printmgr.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -PMDIR="/usr/sadm/admin/printmgr" -CLSDIR="${PMDIR}/classes" -L10NDIR="/usr/share/lib/locale" - -CLASSPATH="${L10NDIR}:${CLSDIR}/pmclient.jar:${CLSDIR}/pmserver.jar" -LD_LIBRARY_PATH="${PMDIR}/lib" - -export CLASSPATH LD_LIBRARY_PATH - -exec /usr/java/bin/java com.sun.admin.pm.client.pmTop $1 diff --git a/usr/src/cmd/print/printmgr/com/Makefile b/usr/src/cmd/print/printmgr/com/Makefile deleted file mode 100644 index 78a71dc67e..0000000000 --- a/usr/src/cmd/print/printmgr/com/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# Makefile for print manager -# -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = sun - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/print/printmgr/com/sun/Makefile b/usr/src/cmd/print/printmgr/com/sun/Makefile deleted file mode 100644 index 9bfd4551f3..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# Makefile for print manager -# -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = admin - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/Makefile b/usr/src/cmd/print/printmgr/com/sun/admin/Makefile deleted file mode 100644 index 08b0c55bec..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# Makefile for print manager -# -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = pm - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/Makefile b/usr/src/cmd/print/printmgr/com/sun/admin/pm/Makefile deleted file mode 100644 index efbf6fee75..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# Makefile for print manager -# -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = server client - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/BST.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/BST.java deleted file mode 100644 index 5bdd31d333..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/BST.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * BST.java - * Simple binary search tree implementation for help articles - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; -import java.util.*; -import com.sun.admin.pm.server.*; - - -public class BST extends Object { - - // these should be protected... - public BST left = null; - public BST right = null; - public BST parent = null; - public BSTItem data; - - static public int comparisons; - - public BST(BSTItem theItem) { - // Debug.info("HELP: New BST(" + theItem + ")"); - - left = right = null; - data = theItem; - } - - - public BST() { - this(new BSTItem("", null)); - } - - public BST insert(String key, Object data) { - return insert(new BSTItem(key, data)); - } - - - // normal bst insertion - public BST insert(BSTItem theItem) { - - int comp = data.compare(theItem); - BST node = null; - - if (comp == 0) { - Debug.info("HELP: Duplicate insert: " + - theItem.toString()); - } else if (comp > 0) { - if (left != null) - left.insert(theItem); - else - left = node = new BST(theItem); - } else if (comp < 0) { - if (right != null) - right.insert(theItem); - else - right = node = new BST(theItem); - } - - return node; - } - - - public BST find_tree(String newKey) { - return find_tree(newKey, true); - } - - public BSTItem find(String newKey) { - return find(newKey, true); - } - - - public BST find_tree(String newKey, boolean exactMatch) { - /* - * Debug.info("HELP: Finding " +(exactMatch ? "exact " : "partial ") + - * newKey); - */ - - BST rv = null; - int comp = data.compare(newKey, exactMatch); - - ++comparisons; - - if (comp > 0) { - if (left != null) - rv = left.find_tree(newKey, exactMatch); - } else if (comp < 0) { - if (right != null) - rv = right.find_tree(newKey, exactMatch); - } else { - rv = this; - // Debug.info("HELP: Found " + newKey + " in " + data); - } - - return rv; - } - - public BSTItem find(String newKey, boolean exactMatch) { - Debug.info("HELP: Finding " +(exactMatch ? "exact " : "partial ") + - newKey); - - BSTItem rv = null; - int comp = data.compare(newKey, exactMatch); - - ++comparisons; - - if (comp > 0) { - if (left != null) - rv = left.find(newKey, exactMatch); - } else if (comp < 0) { - if (right != null) - rv = right.find(newKey, exactMatch); - } else { - Debug.info("HELP: Found " + newKey + " in " + data); - rv = this.data; - } - - return rv; - } - - - - public void traverse() { - if (left != null) - left.traverse(); - Debug.info("HELP: Traverse: " + data); - if (right != null) - right.traverse(); - } - - public void traverse_right() { - Debug.info("HELP: Traverse: " + data); - if (right != null) - right.traverse(); - } - - - public void traverse_find(String key) { - if (left != null) - left.traverse_find(key); - if (data.compare(key, false) < 0) - return; - Debug.info("HELP: Traverse_find: " + data.key); - if (right != null) - right.traverse_find(key); - } - - // empty search string is a wildcard... - public void traverse_find_vector(Vector v, String key) { - /* - * Debug.info("HELP: traverse_find_vector: node " + - * data.key + "[" +(left!=null?left.data.key:"null") + "]" + - * "[" +(right!=null ?right.data.key:"null") + "]" + - * " seeking " + key); - */ - int c = 0; - - if (key.length() > 0) - c = data.compare(key, false); - - /* - * Debug.info("HELP: traverse_find_vector: compare " + - * data.key + " to "+ key + " = " + c); - */ - - if (c >= 0 && left != null) - left.traverse_find_vector(v, key); - - if (c == 0) { - // Debug.info("HELP: traverse_find_vector: adding " + data.key); - v.addElement(data.data); - } - - if (c <= 0) { - if (right != null) - right.traverse_find_vector(v, key); - } - } - - - public void dump() { - Debug.info("HELP: \nDump: this = " + data.key); - - if (left != null) - Debug.info("HELP: Dump: left = " + left.data.key); - else - Debug.info("HELP: Dump: left = null"); - - - if (right != null) - Debug.info("HELP: Dump: right = " + right.data.key); - else - Debug.info("HELP: Dump: right = null"); - - if (left != null) - left.dump(); - if (right != null) - right.dump(); - - } - - public static void main(String args[]) { - BSTItem root = new BSTItem("Root"); - BSTItem a = new BSTItem("Alpha"); - BSTItem b = new BSTItem("Bravo"); - BSTItem c = new BSTItem("Charlie"); - BSTItem d = new BSTItem("Delta"); - BSTItem e = new BSTItem("Echo"); - BSTItem x = new BSTItem("Xray"); - BSTItem aa = new BSTItem("aspect"); - BSTItem ab = new BSTItem("assess"); - BSTItem ad = new BSTItem("assist"); - BSTItem ae = new BSTItem("asphalt"); - BSTItem af = new BSTItem("asap"); - BSTItem ag = new BSTItem("adroit"); - BSTItem ah = new BSTItem("adept"); - BSTItem ai = new BSTItem("asdf"); - - BST bst = new BST(root); - - BST.comparisons = 0; - bst.insert(a); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.insert(x); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.insert(e); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.insert(c); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.insert(b); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.insert(d); - System.out.println(BST.comparisons + - " comparisons\n"); - - bst.insert(aa); - bst.insert(ab); - bst.insert(ad); - bst.insert(ae); - bst.insert(af); - bst.insert(ag); - bst.insert(ah); - bst.insert(ai); - - bst.traverse(); - - BST.comparisons = 0; - bst.find("Echo"); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.find("Xray"); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.find("Delta"); - System.out.println(BST.comparisons + - " comparisons\n"); - BST.comparisons = 0; - bst.find("Root"); - System.out.println(BST.comparisons + - " comparisons\n"); - bst.find("Alpha"); - - bst.dump(); - if (bst.left != null) - bst.left.dump(); - if (bst.right != null) - bst.right.dump(); - - { - Debug.info("HELP: Looking for a"); - BST result = bst.find_tree("a", false); - result.traverse_find("a"); - - Debug.info("HELP: Looking for as"); - result = result.find_tree("as", false); - result.traverse_find("as"); - - Debug.info("HELP: Looking for ass"); - result = result.find_tree("ass", false); - result.traverse_find("ass"); - - Debug.info("HELP: Looking for ad"); - result = bst.find_tree("ad", false); - result.traverse_find("ad"); - } - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/BSTItem.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/BSTItem.java deleted file mode 100644 index 0ad3b5f8fe..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/BSTItem.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * BSTItem.java - * Simple binary search tree implementation for help articles - */ - -package com.sun.admin.pm.client; - -import java.lang.*; -import com.sun.admin.pm.server.*; - -public class BSTItem extends Object { - public String key; - public Object data; - public int handle = UNINITIALIZED; - - static int serial = 0; - static final int UNINITIALIZED = -1; - - public BSTItem(String newKey) { - this(newKey, null); - } - - public BSTItem(String newKey, Object obj) { - key = newKey.toLowerCase(); - data = obj; - handle = serial++; - } - - public String toString() { - return new String("Item " + key + " (" + handle + ")"); - } - - public int compare(BSTItem otherItem, boolean exact) { - - return compare(otherItem.key, exact); - } - - - public int compare(BSTItem otherItem) { - return compare(otherItem, true); - } - - public int compare(String otherKey) { - return compare(otherKey, true); - } - - - public int compare(String otherKey, boolean exact) { - - /* - * System.out.println(this.toString() + " comparing " + - * (exact ? "exact" : "partial") + " to " + otherKey); - */ - - int rv = 0; - - if (otherKey != null && otherKey != "") - rv = exact ? - key.compareTo(otherKey) : - compareSub(otherKey.toLowerCase()); - - /* - * System.out.println( - * "Compare: " + key + " to " + otherKey + " -> " + rv); - */ - - return rv; - } - - - public int compareSub(String s) { - Debug.info("HELP: compareSub: " + key + " to " + s); - - int rv = 0; - try { - rv = key.substring(0, s.length()).compareTo(s); - } catch (Exception x) { - Debug.info("HELP: compareSub caught: " + x); - rv = -1; - } - return rv; - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/Constants.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/Constants.java deleted file mode 100644 index 12ffe37f5d..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/Constants.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Comment which describes the contents of this file. - * - * Constants.java - * Common constants for Printer Manager - */ - -package com.sun.admin.pm.client; - -/* - * pmConstants.java - * defines constants used with print manager - */ - -public interface Constants -{ - // Buttons - int OK = 1; - int APPLY = 2; - int RESET = 3; - int CANCEL = 4; - int HELP = 5; - - // Buttons for user access list - int ADD = 6; - int DELETE = 7; - - // Printer type to add/modify - int ADDLOCAL = 1; - int ADDNETWORK = 2; - int MODIFYATTACHED = 3; - int MODIFYREMOTE = 4; - int MODIFYNETWORK = 5; - - // Printer connection types - int ATTACHED = 1; - int NETWORK = 2; - - // Useful Constants - int MAXPNAMELEN = 20; - - // Combo Listener - int PORT = 1; - int TYPE = 2; - int MAKE = 3; - int MODEL = 4; - int PPD = 5; - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/Makefile b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/Makefile deleted file mode 100644 index f80827be30..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/Makefile +++ /dev/null @@ -1,144 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Makefile for Java Print Manager client -# -include $(SRC)/Makefile.master -include $(SRC)/cmd/Makefile.cmd - - -CLASSPATH= $(SRC)/cmd/print/printmgr - -CLASSFILES = Constants.class \ - pmAuthOptions.class \ - pmHelpFrame.class \ - pmTop.class \ - pmResources.class \ - pmCopyright.class \ - pmUtility.class \ - pmCalls.class \ - pmLoad.class \ - pmDelete.class \ - pmAccess.class \ - pmButtonScreen.class \ - pmInstallScreen.class \ - pmInstallPrinter.class \ - pmOKCancelDialog.class \ - pmMessageDialog.class \ - pmLogin.class \ - pmLogDisplay.class \ - pmHelpDetailPanel.class \ - pmHelpContent.class \ - pmHelpController.class \ - pmHelpDetailPanel.class \ - pmHelpIndexPanel.class \ - pmHelpItem.class \ - pmHelpRepository.class \ - pmHelpSearchPanel.class \ - BST.class \ - BSTItem.class \ - pmGuiException.class \ - pmHelpException.class \ - pmAddAccessFailedException.class \ - pmAddPrinterFailedException.class \ - pmIncompleteFormException.class \ - pmLoginFailedException.class \ - pmModifyPrinterFailedException.class \ - pmPrinterExistsException.class \ - pmDeleteFailedException.class \ - pmMustBeRemoteServerException.class \ - pmUserCancelledException.class \ - pmNullSelectedPrinterException.class \ - pmNeedPPDCacheException.class \ - pmCacheMissingPPDException.class \ - pmFindFrame.class \ - pmAboutBox.class \ - pmFrame.class \ - pmButton.class \ - pmTextField.class \ - pmAuthOptions.class \ - pmOther.class - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/admin \ - $(ROOT)/usr/share/lib/locale/com/sun/admin/pm \ - $(ROOT)/usr/share/lib/locale/com/sun/admin/pm/client - -MSGDIR = $(ROOT)/usr/share/lib/locale/com/sun/admin/pm/client -MSGJAVAFILES = pmResources.java pmHelpResources.java -MSGFILES = $(MSGJAVAFILES:%=$(MSGDIR)/%) - -$(MSGFILES):= FILEMODE = 644 - -CLEANFILES= *.class pmHelpResources.java pmCopyright.java \ - helptools/*.class helptools/parsehelp -CLOBBERFILES= - -# -# raw-text help files -# -HELPFILES= ./raw-help/*.rawhlp - -# -# text file containing comments to be bound into the help resource bundle -# -HELP_COMMENTS=./help-l10n-comments.txt - -install all: pmCopyright.java $(CLASSFILES) help - -pmCopyright.java: pm_gen_copyright - $(SH) ./pm_gen_copyright - -# -# pmHelpResources.java is generated by parsing raw help text -# -pmHelpResources.java: $(HELP_COMMENTS) \ - $$(HELPFILES) \ - helptools/parseMain.class \ - helptools/parsehelp - $(RM) pmHelpResources.* - helptools/parsehelp -C $(HELP_COMMENTS) -D $(CLASSPATH) \ - -J $(JAVA_ROOT) $(HELPFILES) - -help: pmHelpResources.class - -_msg: $(MSGDIRS) help $(MSGFILES) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -jstyle: - jstyle $(JAVAFILES) - -lint: -clean: - $(RM) $(CLEANFILES) -clobber: clean diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/help-l10n-comments.txt b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/help-l10n-comments.txt deleted file mode 100644 index d7440d8460..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/help-l10n-comments.txt +++ /dev/null @@ -1,242 +0,0 @@ - -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 -or http://www.opensolaris.org/os/licensing. -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 - -Localization Notes for the Oracle Solaris Print Manager -3/16/99 - -1. Overview - The help documentation tree consists of a collection of Articles, - each relating to a specific dialog, message, procedure, or - other topic. The text, keywords, and metadata comprising the - entire set of Articles is delivered in a single (large) - ResourceBundle per locale. - - Each article consists of several parts, all of which must be - defined within the ResourceBundle. These parts are called Tag, - Title, Content, Keywords, and See-Also. Title, Content, and - Keywords must be localized while Tag and See-Also must not. - - The Tag is an identifier unique to each Article. The application - uses Tags to refer to specific Articles. The ResourceBundle uses - each Article's Tag to form the keys which identify the - strings comprising the Article. - - The strings used as keys to identify the various parts of the - articles in the ResourceBundle are in the form of a dotted pair, - where the left side identifies the Tag of the Article to which - this string belongs and the right side describes which part of - that Article the string embodies. - - The suffixes used to identify the Tag, Title, Content, Keywords, - and See-Also parts of a help article's resources are ".tag", - ".title", ".content", ".keyword", and ".seealso" respectively. - - Examples: The key "ToAddPrinter.title" is associated with a - localizable string that represents the title of the article whose - tag is "ToAddPrinter". The key "ToDeletePrinter.content" refers to - a localizable string which contains the content of the help article - itself. - - -2. Structure of Help Articles - -2.1 Tags - Each Article is associated with a unique identifier called a Tag. - Tags are used internally and are never directly visible to users. - - A Tag is a case-sensitive string of alphanumeric 7-bit ASCII - characters containing no embedded whitespace or punctuation. - - For convenience, an article's Tag is usually formed by taking the - title and removing whitespace and punctuation; for example, - the article titled "Troubleshooting Printer Problems" might have - the Tag "TroubleShootingPrinterProblems". Note that this is a - mnemonic device only and in no way engenders a dependency between - the non-localizable Tag, which must be embedded in the - application's source code, and the article's title itself, which - must be localized. - - *TAGS ARE NOT TO BE LOCALIZED!* - - -2.2 Title and Content - Each Article must contain a Title and some Content. - - The Title is an arbitrary localizable string which will be - presented to the user upon viewing its associated Article. - - The Content of an Article consists of a block of localizable text - which may contain a limited set of embedded HTML tags (subject to - restrictions described below). - - Since the Content is displayed in a window whose size may be - adjusted by the user, its layout cannot be completely controlled by - the author. The Help display relies on word-wrapping and HTML - formatting to ensure correct appearance. - - The viewable Content of an Article is authored in a tiny subset of - HTML which can be reliably rendered in the Help component. The - intention is to provide a simple facility for controlling the - appearance of the text and for handling paragraph and line breaks. - - The supported capabilities are: - - . Emphasize sections of text by bolding: <b> ... </b> - - . Line breaks: <br> - - . Paragraph breaks: <p> - - No other HTML tags should be embedded in the Content as they - may not produce the expected results. No hyperlinks or images - are supported! - - Note that while the content itself may be localized, the HTML tags - embedded within the content should be left in ASCII. - - *BOTH TITLE AND CONTENT MUST BE LOCALIZED!* - - -2.3 Keywords - - Users may search the collection of help articles by specifying one - or more keywords (in the locale's representation) which are matched - against the set of Articles. Those articles whose keyword list has - one or more matches with the user's list will then be viewable. - - Each Article may specify a (possibly empty) list of keywords - separated by whitespace and containing no commas or punctuation. - The whitespace in this list of keywords is used only to separate - individual keywords. - - Each Keyword in the list must be a string of localizable - alphanumeric text containing no whitespace (punctuation marks such - as "-" may be OK). - - *KEYWORDS MUST BE LOCALIZED!* - - -2.4 See-Also - - Each article may refer to other Articles by presenting the user - with a "See-Also" list when the Article is viewed. This user's - view of this list contains the Titles of the specified articles, - and clicking a title causes that article to be presented. - - The See-Also list associated with a particular Article consists of - a (possibly empty) list containing Tags of other articles separated - by whitespace and containing no commas or punctuation. The list of - Titles corresponding to these Tags will be displayed to the user in - the same order that it appears in the definition of the Article. - - *SEE-ALSO ITEMS ARE NOT TO BE LOCALIZED!* - - -3. Notes on Representation of Content - - The internal representation of the Content component of each - article is as a single (long) Java String. - - Java permits the static initialization of Strings to use - catenation on the right-hand side of the assignment. - For example, the Java statements - String s = "foo bar"; - and - String s = "foo" + " " + bar; - will result in an identical assignment. - - Since the HTML rendering process which displays the resource to - the user ignores whitespace and line breaks, the initializations - of Content strings in the Help ResourceBundle exploit this approach - to make the code more readable and facilitate the localization - process. - - Note that the breaking up of the Content string into source lines is - transparent to the application; details of the source file's - appearance can change across localizations (assuming that tag names - are maintained correctly). - - As an example, consider the ResourceBundle entry which defines the - Content portion of a help article whose tag is "ToDeletePrinter". - This entry might appear in the ResourceBundle source as - - { "ToDeletePrinter.content", - - "This is some help content which would extend across several " + - "lines of text if it were all in a single long string. " + - "Since we can separate the one long string into several " + - "short ones, " + - "the source file is much more easily readable. " - } - - -4. Previewing Help Article Content - - It is possible to use an ordinary HTML browser to view the Content of - all the help Articles in a ResourceBundle. To do so requires the - extraction and formatting of the strings in the ResourceBundle which - comprise the Content portions of all included Articles. - - One approach is to create a simple script which acts as a filter; its - input is the pmHelpResources.java ResourceBundle source file and its - output is a stream of HTML which can be saved to a file and viewed in - a browser. - - The use of such a script can facilitate the localization process by - enabling localization teams to view a particular version of the - ResourceBundle as work on it progresses. - - An example of a script which performs the required formatting and - extraction is as follows: - - ----------------------- - #!/bin/ksh - # - # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. - # All rights reserved. - # - # This filter accepts a pmHelpResources.java file as input - # and produces formatted HTML as output. - # - - while read line; do - echo "$line" | grep '^.*{".*\.tag"' > /dev/null - if [[ $? == 0 ]]; then - print -n "<br> <h2> " - print -n `echo "$line" | sed s/'\.'/\ / | \ - sed s/\"/\ /g | awk '{print \$2}'` - print " </h2>" - fi - - echo "$line" | grep '^\".*+$' | sed s/^\"//g | sed s/\"\ +\$// - - done - ----------------------- - - Usage of this script (assuming it is named 'extract') would be: - % extract < pmHelpResources.java > content.html - - -5. Support - - For further assistance please contact: - Claude Noshpitz, clauden@eng.sun.com. - - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helpTest.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helpTest.java deleted file mode 100644 index 8af71ace2a..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helpTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * helpTest.java - * Test harness for help subsystem - */ - -package com.sun.admin.pm.client; - -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.JPanel; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.*; -import com.sun.admin.pm.server.*; - -class helpTest { - static private pmHelpFrame helpFrame = null; - - public static void main(String args[]) { - - Debug.setDebugLevel(Debug.ERROR); - - JFrame frame = new JFrame("Help Test Tool"); - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) {System.exit(0); } - }); - - helpFrame = new pmHelpFrame(); - helpFrame.setLocation(180, 180); - - - JList theList = new JList(); - theList.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - JList l = (JList) e.getSource(); - int i = l.locationToIndex(e.getPoint()); - Debug.message("doubleclick index: " + i); - if (i >= 0) { - String s = (String) l.getModel().getElementAt(i); - Debug.message("doubleclick: " + s); - helpFrame.showHelp(s); - } - } - } - }); - - JScrollPane scrollPane = new JScrollPane(); - scrollPane.getViewport().setView(theList); - - JPanel tp = new JPanel(); - tp.setLayout(new GridBagLayout()); - GridBagConstraints pc = new GridBagConstraints(); - pc.insets = new Insets(5, 5, 0, 5); - // pc.fill = GridBagConstraints.HORIZONTAL; - pc.weightx = 1.0; - pc.anchor = GridBagConstraints.WEST; - pc.gridx = 0; - pc.gridy = GridBagConstraints.RELATIVE; - - tp.add(new JLabel("Double-click a tag to load it."), pc); - pc.insets = new Insets(0, 5, 5, 5); - tp.add(new JLabel(""), pc); - - JPanel p = new JPanel(); - p.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(5, 5, 5, 5); - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridheight = 1; - c.gridx = 0; - c.gridy = 0; - c.weightx = 1.0; - c.weighty = 0.0; - - c.anchor = GridBagConstraints.NORTH; - p.add(tp, c); - - JPanel pp = new JPanel(); - pp.setLayout(new BorderLayout()); - pp.add(scrollPane, "Center"); - - c.gridy = GridBagConstraints.RELATIVE; - c.gridheight = 0; - c.weighty = 1.0; - c.weightx = 0.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.EAST; - - p.add(pp, c); - - p.setBorder(BorderFactory.createEtchedBorder()); - - frame.getContentPane().add("Center", p); - - helpTestButtonPanel bp = new helpTestButtonPanel(); - frame.getContentPane().add("South", bp); - - p = new JPanel(); - Vector v = new Vector(); - - ResourceBundle bundle = null; - - try { - bundle = ResourceBundle.getBundle( - "com.sun.admin.pm.client.pmHelpResources"); - } catch (MissingResourceException e) { - System.out.println("Could not load pmHelpResources file"); - System.exit(-1); - } - - Enumeration e = bundle.getKeys(); - while (e.hasMoreElements()) { - String key = (String) e.nextElement(); - if (key.endsWith(".tag")) { - String tagName = null; - try { - tagName = bundle.getString(key); - } catch (MissingResourceException x) { - System.out.println("Unable to find tag for " + key); - continue; - } - v.addElement(tagName); - } - } - - theList.setListData(v); - theList.removeSelectionInterval( - theList.getMinSelectionIndex(), - theList.getMaxSelectionIndex()); - // theList.addSelectionInterval(3, 5); - // theList.disable(); - - frame.pack(); - frame.setVisible(true); - frame.repaint(); - System.err.println("Hello from main"); - - } - - public void showHelpItem(String tag) { - helpFrame.showHelp(tag); - } - -} - - class helpTestButtonPanel extends JPanel { - JButton dismiss; - - public helpTestButtonPanel() { - add(dismiss = new JButton("Done")); - dismiss.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - System.exit(0); - } - }); - } - } - - - - - - - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/extract b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/extract deleted file mode 100644 index b05f85fd20..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/extract +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 (c) 1999, by Sun Microsystems, Inc. -# All rights reserved. -# -# This filter accepts a pmHelpResources.java file as input -# and produces formatted HTML as output. -# - -while read line; do - echo "$line" | grep '^.*{".*\.tag"' > /dev/null - if [[ $? == 0 ]]; then - print -n "<br> <h2> " - print -n `echo "$line" | sed s/'\.'/\ / | \ - sed s/\"/\ /g | awk '{print \$2}'` - print " </h2>" - fi - - echo "$line" | grep '^\".*+$' | sed s/^\"//g | sed s/\"\ +\$// - -done diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/parseMain.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/parseMain.java deleted file mode 100644 index 4dbb34bb4e..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/parseMain.java +++ /dev/null @@ -1,811 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -import java.io.*; -import java.util.*; -import java.lang.*; - - -class ResourceWriter { - - BufferedWriter theWriter = null; - String theTag = null; - - static final String NL = new String("\n"); - static final String LOCALIZE = new String("// LOCALIZE"); - static final String NOLOCALIZE = new String("// DO NOT LOCALIZE"); - static final String INDENT = new String(" "); - static final String INDENT_2 = new String(INDENT + INDENT); - static final String COMMENTBLOCK_START = new String("/*"); - static final String COMMENTBLOCK_END = new String(" */"); - static final String COMMENTLINE_START = new String(" * "); - - public ResourceWriter(BufferedWriter w) { - theWriter = w; - } - - public void close() throws IOException { - theWriter.flush(); - theWriter.close(); - } - - protected void writenl(String s) throws IOException { - theWriter.write(s, 0, s.length()); - theWriter.newLine(); - } - - protected void write(String s) throws IOException { - theWriter.write(s, 0, s.length()); - } - - public void fileheader() throws IOException { - writenl("/* "); - writenl(" * GENERATED CODE"); - writenl(" *"); - writenl(" * Copyright 1999 Sun Microsystems, Inc."); - writenl(" * All rights reserved."); - writenl(" *"); - writenl(" */"); - writenl(""); - writenl("package com.sun.admin.pm.client;"); - writenl("import java.util.*;"); - } - - public void classheader(String className) throws IOException { - writenl("public class " + className + - " extends ListResourceBundle {"); - writenl(INDENT + - "static final Object[][] pmHelpBundlecontents = {"); - } - - public void footer() throws IOException { - writenl(INDENT + "};"); - writenl(INDENT + "public Object[][] getContents() {"); - writenl(INDENT_2 + "return pmHelpBundlecontents;"); - writenl(INDENT + "}"); - writenl("}"); - } - - - public void setTag(String tag) throws IOException { - theTag = new String(tag); - } - - public void tag(String tag) throws IOException { - if (tag != null) { - writenl(NL + INDENT_2 + NOLOCALIZE); - writenl(INDENT_2 + - "{\"" + theTag + ".tag\", \"" + tag + "\"},"); - } - } - - public void title(String title) throws IOException { - if (title != null) { - writenl(NL + INDENT_2 + LOCALIZE); - writenl(INDENT_2 + - "{\"" + theTag + ".title\", \"" + title + "\"},"); - } - } - - public void seealso(String seealso) throws IOException { - if (seealso != null) { - writenl(NL + INDENT_2 + NOLOCALIZE); - writenl(INDENT_2 + - "{\"" + theTag + ".seealso\", \"" + seealso + "\"},"); - } - } - - public void keywords(String keywords) throws IOException { - if (keywords != null) { - writenl(NL + INDENT_2 + LOCALIZE); - writenl(INDENT_2 + - "{\"" + theTag + ".keywords\", \"" + keywords + "\"},"); - } - } - - public void content(Vector content) throws IOException { - if (content == null) - return; - - writenl(NL + INDENT_2 + LOCALIZE); - writenl(INDENT_2 + "{\"" + theTag + ".content\","); - - Enumeration e = content.elements(); - while (e.hasMoreElements()) { - String s = (String) e.nextElement(); - if (s.length() == 0) { - if (e.hasMoreElements()) - continue; - else { - writenl(INDENT_2 + " \"\"\n },"); - break; - } - } - String endOfLine = (e.hasMoreElements() ? - " +" : - "\n },"); - writenl(INDENT_2 + " \"" + s + " \"" + endOfLine); - } - } - - public void delimiter() throws IOException { - writenl(NL); - } - - public void commentStart() throws IOException { - writenl(COMMENTBLOCK_START); - } - - public void commentEnd() throws IOException { - writenl(COMMENTBLOCK_END); - } - - public void comment(String s) throws IOException { - writenl(COMMENTLINE_START + s); - } -} - - - - -class Article { - String theTitle; - String theKeywords; - String theSeeAlso; - Vector theContent; - String theTag; - - Reader r; - - public void read(Reader theReader) { - r = theReader; - - Tag theTag = null; - - try { - while (true) { - theTag = readNextTag(); - Debug.message("Article read: " + theTag); - - if (theTag instanceof CommentTag) { - Debug.message("Comment ignored"); - } else if (theTag instanceof TitleTag) { - theTitle = theTag.content; - } else if (theTag instanceof ContentTag) { - theContent = theTag.contentVector; - } else if (theTag instanceof SeeAlsoTag) { - theSeeAlso = theTag.content; - } else if (theTag instanceof KeywordsTag) { - theKeywords = theTag.content; - } else { - Debug.message("Unknown tag: " + theTag); - } - } - } catch (IOException x) { - Debug.message("Article read caught " + x); - } - - - } - - - int localread() throws IOException { - int ch = r.read(); - if (ch == -1) { - Debug.message("localread: eof"); - throw new IOException(); - } - // Debug.message("localread: " + ch); - return ch; - } - - - /* - * read the word within tagOpen/tagClose pair - */ - String readTagName() throws IOException { - String rv = null; - int ch; - StringBuffer b = new StringBuffer(); - - while (true) - if (localread() == HelpSyntax.tagOpen) - break; - - Debug.message("readTagName: got a tagOpen"); - - while (true) { - ch = localread(); - if (ch == HelpSyntax.tagClose) - break; - else - b.append((char) ch); - } - - Debug.message("readTagName: " + (new String(b)).trim()); - return (new String(b)).trim(); - } - - - Tag readNextTag() throws IOException { - Tag rv = null; - int ch; - StringBuffer b; - - String tag = readTagName(); - Debug.message("readNextTag name: " + tag); - - if (tag.equalsIgnoreCase(HelpSyntax.tagTitle)) { - rv = new TitleTag(); - rv.read(r); - } else if (tag.equalsIgnoreCase(HelpSyntax.tagKeywords)) { - rv = new KeywordsTag(); - rv.read(r); - } else if (tag.equalsIgnoreCase(HelpSyntax.tagSeeAlso)) { - rv = new SeeAlsoTag(); - rv.read(r); - } else if (tag.equalsIgnoreCase(HelpSyntax.tagContent)) { - rv = new ContentTag(); - rv.readMultipleLines(r); - } else { - Debug.message("Bad tag: " + tag); - } - return rv; - } - - - public String toString() { - return new String("Title <" + theTitle + - "> Keywords <" + theKeywords + - "> See-Also <" + theSeeAlso + - "> Content <" + theContent + ">"); - } -} - - -class HelpSyntax { - public final static int tagOpen = '<'; - public final static int tagClose = '>'; - public final static String startComment = "!-"; - public final static String endComment = "--"; - public final static String tagContent = "CONTENT"; - public final static String tagTitle = "TITLE"; - public final static String tagSeeAlso = "SEEALSO"; - public final static String tagKeywords = "KEYWORDS"; -} - -class ParseException extends Exception { -} - -class BadTagException extends ParseException { -} - -class SyntaxErrorException extends ParseException { -} - -abstract class Tag { - String content; - Vector contentVector; - protected String name; - protected boolean escapeQuotes = false; - - public Tag(String s) { - content = s; - } - - public Tag() { - this(null); - } - - public String toString() { - return new String(this.getClass().getName() + ": " + content); - } - - // respect line spacing, stuff contentVector - public void readMultipleLines(Reader r) throws IOException { - int ch; - StringBuffer b = new StringBuffer(); - Vector v = new Vector(); - boolean spaced = false; - - while (true) { - ch = r.read(); - if (ch == -1) - break; - - if (ch == '\n') { - v.addElement(new String(b)); - b = new StringBuffer(); - continue; - } - - if (Character.isWhitespace((char) ch)) { - if (spaced == false) { - b.append(" "); - spaced = true; - } - continue; - } - - if (escapeQuotes && ch == '\"') { - b.append("\\\""); - continue; - } - - spaced = false; - if (ch == HelpSyntax.tagOpen) { - boolean localspaced = false; - boolean localopen = true; - Debug.message("Tag: got a tagOpen"); - - StringBuffer tmp = new StringBuffer(); - while ((ch = r.read()) != HelpSyntax.tagClose) { - if (Character.isWhitespace((char) ch)) { - if (localspaced == false) { - tmp.append(" "); - localspaced = true; - } - continue; - } - tmp.append((char) ch); - } - - String t = new String(tmp); - - if ((t.trim()).equalsIgnoreCase("/" + this.name)) { - Debug.message("Tag: close tag = " + t); - break; - } else { - Debug.message("Tag: ignoring bad close tag = " + t); - b.append((char) HelpSyntax.tagOpen); - b.append(t); - b.append((char) HelpSyntax.tagClose); - } - } else { - b.append((char)ch); - } - } - contentVector = v; - Debug.message("Tag: contentVector = " + contentVector); - } - - // catenate input lines, eliminating whitespace - public void read(Reader r) throws IOException { - int ch; - StringBuffer b = new StringBuffer(); - boolean spaced = false; - - while (true) { - ch = r.read(); - if (ch == -1) - break; - - if (Character.isWhitespace((char) ch)) { - if (spaced == false) { - b.append(" "); - spaced = true; - } - continue; - } - - if (escapeQuotes && ch == '\"') { - b.append("\\\""); - continue; - } - - spaced = false; - if (ch == HelpSyntax.tagOpen) { - boolean localspaced = false; - boolean localopen = true; - Debug.message("Tag: got a tagOpen"); - - StringBuffer tmp = new StringBuffer(); - while ((ch = r.read()) != HelpSyntax.tagClose) { - if (Character.isWhitespace((char) ch)) { - if (localspaced == false) { - tmp.append(" "); - localspaced = true; - } - continue; - } - tmp.append((char) ch); - } - - String t = new String(tmp); - - if ((t.trim()).equalsIgnoreCase("/" + this.name)) { - Debug.message("Tag: close tag = " + t); - break; - } else { - Debug.message("Tag: ignoring bad close tag = " + t); - b.append((char) HelpSyntax.tagOpen); - b.append(t); - b.append((char) HelpSyntax.tagClose); - } - } else { - b.append((char)ch); - } - } - content = (new String(b)).trim(); - Debug.message("Tag: content = " + content); - } -} - -class TitleTag extends Tag { - public TitleTag() { - name = HelpSyntax.tagTitle; - } -} - -class SeeAlsoTag extends Tag { - public SeeAlsoTag() { - name = HelpSyntax.tagSeeAlso; - } -} - -class ContentTag extends Tag { - public ContentTag() { - name = HelpSyntax.tagContent; - escapeQuotes = true; - } -} - -class CommentTag extends Tag { - public CommentTag() { - name = null; - } -} - -class KeywordsTag extends Tag { - public KeywordsTag() { - name = HelpSyntax.tagKeywords; - escapeQuotes = true; - } -} - - - -class parseMain { - - static String outputFileName = "pmHelpResources.java"; - static String commentFileName = "comments.txt"; - static int firstFile = 0; - - // returns -1 if error, 0 otherwise - protected static int parseArgs(String[] args) { - int rv = 0; - int i; - - for (i = 0; i < args.length; ++i) { - if (args[i].compareTo("-d") == 0) { - if (args[i].length() > 2) { - outputFileName = args[i].substring(2); - } else { - outputFileName = args[++i]; - } - } else if (args[i].compareTo("-c") == 0) { - if (args[i].length() > 2) { - commentFileName = args[i].substring(2); - } else { - commentFileName = args[++i]; - } - } else if (args[i].compareTo("-v") == 0) { - Debug.setDebugLevel(Debug.WARNING); - } else - break; // unknown arg ==> list of files starts - - } - - firstFile = i; - - /* - * System.out.println("outputFileName = " + outputFileName + - * " commentFileName = " + commentFileName + - * " firstFile = " + firstFile); - */ - - return rv; - } - - - public static void main(String args[]) { - FileReader f = null; - FileWriter fw = null; - String filename = null; - - Debug.setDebugLevel(Debug.ERROR); - - // validate command line - if (args.length == 0) { - System.err.println("At least one filename required."); - System.exit(-1); - } - - if (parseArgs(args) < 0) - System.exit(-1); - - - outputFileName = outputFileName.trim(); - - Debug.warning("Writing to " + outputFileName); - - try { - - // create output file - fw = new FileWriter(outputFileName); - BufferedWriter w = new BufferedWriter(fw); - ResourceWriter rw = new ResourceWriter(w); - - // imports and package statement - rw.fileheader(); - - // comment block - File commentFile = new File(commentFileName); - if (commentFile.exists()) { - rw.delimiter(); - rw.commentStart(); - BufferedReader comments = - new BufferedReader(new FileReader(commentFileName)); - String commentLine; - while ((commentLine = comments.readLine()) != null) - rw.comment(commentLine); - comments.close(); - rw.commentEnd(); - rw.delimiter(); - } else { - Debug.error("Comment file " + commentFileName + - " not found."); - } - - // create class name w/o extension or leading path - File cf = new File(outputFileName); - String className = cf.getName(); - - // class name is output filename w/o extension - int dotIndex = className.indexOf("."); - if (dotIndex < 0) - dotIndex = className.length(); - - className = className.substring(0, dotIndex); - - // class definition - rw.classheader(className); - - // iterate over input files - for (int i = firstFile; i < args.length; ++i) { - filename = args[i]; - Debug.warning("Reading file " + filename); - - try { - f = new FileReader(filename); - } catch (Exception x) { - Debug.fatal(x.toString()); - return; - } - - BufferedReader r = new BufferedReader(f); - - Article a = new Article(); - a.read(r); - // System.out.println(a); - - // process the Article - - String tagName = filenameToTag(filename); - Debug.warning("Creating tag " + tagName); - - // HTML syntax checking on content - if (!validHTMLSyntax(a.theContent)) - throw new IOException( - "Bad HTML syntax in article " + tagName); - - - rw.setTag(tagName); - rw.tag(tagName); - rw.seealso(a.theSeeAlso); - rw.title(a.theTitle); - rw.keywords(a.theKeywords); - rw.content(a.theContent); - rw.delimiter(); - } - - rw.footer(); - rw.close(); - w.close(); - } catch (IOException x) { - Debug.fatal(x.toString()); - - // try to unlink the broken output file - boolean unlink = true; - - try { - fw.close(); - } catch (IOException xx) { - Debug.error(xx.toString()); - unlink = false; - } - - if (unlink) { - File theFile = new File(outputFileName); - - Debug.warning("Deleting file " + outputFileName); - - if (theFile.exists()) - theFile.delete(); - } - - System.exit(-2); - } - } - - - // return true if no syntax errors found - static boolean validHTMLSyntax(String s) { - - if (s == null) - return true; - - // check only for <b>..</b> pairs - - String src = s.toLowerCase(); // html tags are case-neutral - - int i; - - int opens = 0; - for (i = src.indexOf("<b>"); - i != -1; - i = src.indexOf("<b>", i + 1)) - ++opens; - - int closes = 0; - for (i = src.indexOf("</b>"); - i != -1; - i = src.indexOf("</b>", i + 1)) - ++closes; - - // System.out.println("syntax: " + opens + " " + closes); - - return opens == closes; - - } - - // return true if no syntax errors found - static boolean validHTMLSyntax(Vector v) { - String s = new String(); - Enumeration e = v.elements(); - while (e.hasMoreElements()) - s = s + (String) e.nextElement(); - return validHTMLSyntax(s); - } - - /* - * extract the tag name from a filename, possibly containing - * a fully qualified path as well as a complex extension. - */ - static String filenameToTag(String filename) { - - // the help tag is the filename exclusive of path or extensions - - File f = new File(filename); - String s = f.getName(); - int period = s.indexOf('.'); - // System.out.println("filename: " + s); - if (period < 0) - period = filename.length(); - // System.out.println("period = " + period); - return s.substring(0, period); - } - - -} - -class Debug { - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void fatal(String s) { - printIf(s, FATAL); - } - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void error(String s) { - printIf(s, ERROR); - } - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void warning(String s) { - printIf(s, WARNING); - } - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void message(String s) { - printIf(s, MESSAGE); - } - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void setDebugLevel(int lvl) { - if (lvl < ALL || lvl > NONE) - return; - - globalDebugLevel = lvl; - } - - private static void printIf(String s, int lvl) { - if (lvl < globalDebugLevel) - return; - DebugPrint(s); - } - - // here is where we could hide syslog or file destination... - private static void DebugPrint(String s) { - System.out.println(s); // for now - } - - - /** - * Verbosity level to suppress all messages. - */ - static public final int NONE = 5; - - /** - * Verbosity level to log only highest-priority messages. - */ - static public final int FATAL = 4; - - /** - * Verbosity level to log high- and highest-priority messages. - */ - static public final int ERROR = 3; - - /** - * Verbosity level to log medium-, high-, and - * highest-priority messages. - */ - static public final int WARNING = 2; - - /** - * Verbosity level to log low-, medium-, high-, and - * highest-priority messages. - */ - static public final int MESSAGE = 1; - - /** - * Verbosity level to log all messages. - */ - static public final int ALL = 0; - - private static int globalDebugLevel = ERROR; - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/parsehelp.sh b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/parsehelp.sh deleted file mode 100644 index b2050c4ef3..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/helptools/parsehelp.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 (c) 1999, by Sun Microsystems, Inc. -# All rights reserved. -# -# Helper script for processing raw help files. -# Parameters: -# -D <classpath> appends <classpath> to $CLASSPATH -# -J <java_dir> uses <java_dir>/bin/java. Default is /usr/java. -# -V enable verbose runtime messages - - -if [[ $# == 0 ]]; then - echo "One or more raw help files must be specified." - echo "Usage:" - echo " $0 [-D classpath] [-J java_home_dir] [-V] [-C comment_file] [-d destination-file] raw-help-file [raw-help-file]" - exit -1 -fi - -while getopts "D:J:C:V" opt; do - - case $opt in - D) DARG=$OPTARG;; - - J) JARG=$OPTARG;; - - C) COMMENT="-c "$OPTARG;; - - V) VERBOSE="-v";; - - esac -done - -shift $(($OPTIND - 1)) - -#echo "DARG: $DARG JARG: $JARG" -#echo "num left: " $# -#echo "args: $*" - -if [[ x$JARG == x ]]; then - # echo "Using default java" - JAVA_HOME="/usr/java" -else - JAVA_HOME=$JARG -fi - -DIR=$DARG - - -#PATH="$JAVA_HOME/bin:/usr/bin:/usr/sbin:/sbin:.:$PATH" -THREADS_FLAG="native" -CLASSPATH=":.:./helptools:$DIR" - -# echo "Path: $PATH" -# echo "CLASSPATH: $CLASSPATH" -# echo "Java: $JAVA_HOME/bin/java" - -echo "Processing raw help files..." -# $JAVA_HOME/bin/java -fullversion -$JAVA_HOME/bin/java -classpath $CLASSPATH parseMain $COMMENT $VERBOSE $* - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/images/appicon.gif b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/images/appicon.gif Binary files differdeleted file mode 100644 index 76918b6467..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/images/appicon.gif +++ /dev/null diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAboutBox.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAboutBox.java deleted file mode 100644 index fe840bc5af..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAboutBox.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmAboutBox.java - * - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.border.*; - -import com.sun.admin.pm.server.*; - - -public class pmAboutBox extends pmFrame { - public pmButton cancel = null; - String title = pmUtility.getResource("About.Solaris.Print.Manager"); - String copyright = new String(pmUtility.getResource("info_copyright1") - + pmUtility.getCopyrightResource("copyright_year") - + pmUtility.getResource("info_copyright2")); - String version = pmUtility.getResource("info_version"); - String appname = pmUtility.getResource("info_name"); - String contents = new String(appname + "\n" + - version + "\n\n" + - copyright + "\n"); - - public pmAboutBox() { - - super(pmUtility.getResource("About.Solaris.Print.Manager")); - - cancel = new pmButton(pmUtility.getResource("Cancel")); - cancel.setMnemonic(pmUtility.getIntResource("Cancel.mnemonic")); - cancel.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - hideAboutBox(); - } - }); - - // Create a regular text field. - JTextArea textArea = new JTextArea(contents); - Font f = new pmJTextField().getFont(); - Font fb = new Font(f.getName(), f.PLAIN, f.getSize()); - textArea.setOpaque(false); - textArea.setFont(fb); - textArea.setLineWrap(true); - textArea.setWrapStyleWord(true); - textArea.setEditable(false); - textArea.setDisabledTextColor(Color.blue); - - JPanel j1 = new JPanel(); - j1.setBorder(new EmptyBorder(10, 10, 10, 10)); - j1.setLayout(new BorderLayout()); - JScrollPane areaScrollPane = new JScrollPane(textArea); - areaScrollPane.setPreferredSize(new Dimension(270, 175)); - j1.add(areaScrollPane, BorderLayout.CENTER); - - JPanel buttonPanel = new JPanel(); - buttonPanel.setBorder(new EmptyBorder(0, 0, 10, 10)); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); - buttonPanel.add(cancel); - - JPanel bottomPanel = new JPanel(new BorderLayout()); - bottomPanel.add(buttonPanel, BorderLayout.SOUTH); - - Container contentPane = getContentPane(); - contentPane.add(j1, BorderLayout.CENTER); - contentPane.add(bottomPanel, BorderLayout.SOUTH); - - // default button is cancel - cancel.setAsDefaultButton(); - - // handle Esc as cancel - getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("HELP: cancel action"); - hideAboutBox(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - pack(); - repaint(); - - } - - public void hideAboutBox() { - this.setVisible(false); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAccess.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAccess.java deleted file mode 100644 index 13b4c42bf4..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAccess.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Comment which describes the contents of this file. - * - * pmAccess.java - * Add Access To Printer handling - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.util.Vector; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * Window for Edit -> Add Access to a Printer - */ - -public class pmAccess extends pmButtonScreen { - JComboBox portCombo; - pmFrame frame = new pmFrame( - pmUtility.getResource("SPM:Add.Access.To.Printer")); - pmTextField pnameText; - pmTextField snameText; - pmTextField descText; - Boolean makedefault; - JCheckBox defaultp; - Printer newpr = null; - pmTop mytop; - String printer = null; - String server = null; - - String cmdLog = null; - String errorLog = null; - String warnLog = null; - - - final static int OK = 1; - final static int APPLY = 2; - final static int RESET = 3; - final static int CANCEL = 4; - final static int HELP = 5; - - public pmAccess(pmTop mytop) { - - // ensure that pmButton hashtable gets cleaned up - frame.setClearButtonsOnClose(true); - - setLayout(new BorderLayout()); - - this.mytop = mytop; - - // Build the Frame - centerPanel(); - southPanel(); - - /* - * let's try doing this in Show... - * - * // default button is always OK, for now... - * frame.getRootPane().setDefaultButton(okButton); - * - * okButton.setAsDefaultButton(); - */ - - // handle Esc as cancel - this.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - actioncancelButton(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - // enable the pmFrame to set focus to our default comp on activation - frame.setDefaultComponent(pnameText); - - - // following is test code, I think... - Component glass = frame.getGlassPane(); - - glass.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent k) { - Debug.info("Glass: " + k); - } - public void keyReleased(KeyEvent k) { - Debug.info("Glass: " + k); - } - public void keyTyped(KeyEvent k) { - Debug.info("Glass: " + k); - } - }); - - } - - public void centerPanel() { - // Build center panel - JPanel center = new JPanel(); - center.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - // define center constraints - c.insets = new Insets(8, 5, 5, 5); - c.gridheight = 1; - c.gridwidth = 1; - - // build center components - // Create - c.gridx = 0; - c.weightx = c.weighty = 0.0; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - - // Build the labels - c.gridy = 0; - center.add(new JLabel - (pmUtility.getResource("Printer.Name:")), c); - c.gridy = 1; - center.add(new JLabel - (pmUtility.getResource("Printer.Server:")), c); - c.gridy = 2; - center.add(new JLabel - (pmUtility.getResource("Description:")), c); - c.gridy = 3; - center.add(new JLabel - (pmUtility.getResource("Option:")), c); - - // Build the text fields - // Common constraints - c.gridx = 1; - c.ipadx = 15; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.WEST; - c.weightx = c.weighty = 1.0; - - c.gridy = 0; - pnameText = new pmTextField(14); - - center.add(pnameText, c); - - c.gridy = 1; - snameText = new pmTextField(25); - center.add(snameText, c); - - c.gridy = 2; - descText = new pmTextField(25); - center.add(descText, c); - - // Add Choice Menus - ComboBox - c.weightx = c.weighty = 0.0; - c.gridy = 3; - - defaultp = new JCheckBox( - pmUtility.getResource("Default.Printer")); - center.add(defaultp, c); - - add("Center", center); - } - - public void createAccess() throws pmGuiException { - boolean getHostOk = true; - String description = ""; - - newpr = new Printer(mytop.ns); - Debug.message("CLNT: createAccess()"); - pmCalls.debugShowPrinter(newpr); - printer = pnameText.getText().trim(); - server = snameText.getText().trim(); - description = descText.getText(); - - if (printer.equals("")) { - pnameText.requestFocus(); - Debug.message("CLNT:pmAccess:Printer name required."); - throw new pmIncompleteFormException( - pmUtility.getResource("Printer.name.required.")); - } - - if (!Valid.remotePrinterName(printer)) { - pnameText.requestFocus(); - Debug.message("CLNT:pmAccess:Printer name invalid: " + printer); - throw new pmIncompleteFormException( - pmUtility.getResource("Printer.name.invalid.")); - } - - if (server.equals("")) { - snameText.requestFocus(); - Debug.message("CLNT:pmAccess:Server name required."); - throw new pmIncompleteFormException( - pmUtility.getResource("Server.name.required.")); - } - - if (!Valid.serverName(server)) { - snameText.requestFocus(); - Debug.message("CLNT:pmAccess:Server name invalid."); - throw new pmIncompleteFormException( - pmUtility.getResource("Server.name.invalid.")); - } - - try { - if (server.equals(mytop.host.getLocalHostName()) || - server.equals("localhost")) { - snameText.requestFocus(); - getHostOk = false; - } - } catch (Exception e) { - Debug.warning( - "CLNT: pmAccess:createAccess:getLocalHostName exception"); - throw new pmGuiException( - pmUtility.getResource( - "Could.not.get.local.hostname " + e)); - } - - if (!getHostOk) { - Debug.warning( - "CLNT: pmAccess:createAccess:Server name required."); - throw new pmMustBeRemoteServerException( - pmUtility.getResource("Server.name.required.")); - } - - boolean exist; - try { - exist = PrinterUtil.exists(printer, mytop.ns); - } catch (Exception e) { - throw new pmGuiException(e.toString()); - } - - if (exist) { - throw new pmPrinterExistsException(); - } - - if (mytop.ns.getNameService().equals("nis") == true || - mytop.ns.getNameService().equals("ldap") == true) { - try { - if (!mytop.ns.isAuth()) { - pmUtility.doLogin(mytop, frame); - } - } catch (pmUserCancelledException e) { - Debug.message("CLNT:pmAccess:user cancelled login"); - throw new pmUserCancelledException( - pmUtility.getResource( - "User.cancelled.login.")); - } catch (pmGuiException e) { - Debug.message( - "CLNT:pmAccess:login nis/ldap failed: " + e); - throw new pmLoginFailedException(); - } catch (Exception e) { - Debug.message( - "CLNT:pmAccess:login nis/ldap failed: " + e); - throw new pmLoginFailedException(); - } - } - - Debug.message("CLNT:pmAccess:checkbox: " + defaultp.isSelected()); - - // Check for confirmation option - if (((mytop.getConfirmOption() == true) && (confirmAction() == true)) - || (mytop.getConfirmOption() == false)) { - - // Set the printer attributes - newpr.setPrinterName(printer); - newpr.setPrintServer(server); - newpr.setComment(description); - if (defaultp.isSelected()) - newpr.setIsDefaultPrinter(true); - - frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - boolean failed = false; - try { - newpr.addRemotePrinter(); - } catch (Exception e) { - failed = true; - Debug.warning( - "CLNT:pmAccess:addRemotePrinter caught:" + e); - } - - frame.setCursor(Cursor.getDefaultCursor()); - - gatherLogs(); - dumpLogs("CLNT:pmAccess:createAccess()"); - - pmCalls.debugShowPrinter(newpr); - - mytop.setLogData(cmdLog, errorLog, warnLog); - mytop.showLogData( - pmUtility.getResource("Add.Access.To.Printer")); - - mytop.pmsetPrinterList(); - mytop.clearSelected(); - mytop.listTable.clearSelection(); - - if (failed) - throw new pmAddAccessFailedException(errorLog); - - } - } - - public void clearAccessInput() { - try { - pnameText.setText(""); - snameText.setText(""); - descText.setText(""); - if (defaultp.isSelected()) - defaultp.doClick(); - } catch (Exception e) { - // ignore??? - // throw new pmGuiException("pmAccess: Error clearAccessInput: " + e); - Debug.warning("CLNT:pmAccess: Error clearAccessInput: " + e); - } - } - - - - public boolean confirmAction() { - if (mytop.getConfirmOption() == true) { - pmOKCancelDialog d = new pmOKCancelDialog(frame, - pmUtility.getResource("Action.Confirmation"), - pmUtility.getResource( - "Continue.creating.access.for.this.printer?")); - d.setVisible(true); - if (d.getValue() != JOptionPane.OK_OPTION) { - pmMessageDialog m = new pmMessageDialog(frame, - pmUtility.getResource("Warning"), - pmUtility.getResource("Operation.Cancelled")); - m.setVisible(true); - return false; - } - } - return true; - } - - void gatherLogs() { - cmdLog = newpr.getCmdLog(); - errorLog = newpr.getErrorLog(); - warnLog = newpr.getWarnLog(); - } - - - void dumpLogs(String who) { - Debug.message(who); - Debug.message(who + " command: " + cmdLog); - Debug.message(who + " warnings: " + warnLog); - Debug.message(who + " errors: " + errorLog); - } - - // returns true if success, false otherwise - boolean doAction() { - boolean rv = false; - - try { - createAccess(); - rv = true; // only if it didn't throw! - } catch (pmIncompleteFormException ix) { - Debug.warning( - "CLNT:pmAccess:incomplete form " + ix.getMessage()); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - ix.getMessage(), - mytop, - "AddAccessFailed"); - m.setVisible(true); - } catch (pmPrinterExistsException ex) { - Debug.warning("CLNT:pmAccess:printer exists"); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource("The.specified.printer.already.exists.")); - m.setVisible(true); - } catch (pmMustBeRemoteServerException rx) { - Debug.warning("CLNT:pmAccess:server must be remove."); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "The.server.must.be.a.remote.server."), - mytop, - "RemoteServer"); - m.setVisible(true); - - } catch (pmLoginFailedException lx) { - Debug.warning("CLNT:pmAccess:Required login failed"); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource("Required.login.failed."), - mytop, - "LoginFailed"); - m.setVisible(true); - - } catch (pmAddAccessFailedException ax) { - Debug.warning( - "CLNT:pmAccess:add access failed " + ax.getMessage()); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - ax.getMessage(), - mytop, - "AddAccessFailed"); - m.setVisible(true); - - } catch (pmUserCancelledException cx) { - Debug.message( - "CLNT:pmAccess:createAccess: User cancelled namespace login"); - } catch (pmGuiException gx) { - Debug.warning( - "CLNT:pmAccess:Application Error" + gx.getMessage()); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Application.Error"), - gx.getMessage()); - m.setVisible(true); - - } finally { - // clearAccessInput(); - } - return rv; - } - - - public void pmScreendispose() { - frame.dispose(); - } - - public void actionokButton() { - Debug.message("CLNT:pmAccess:actionokButton()"); - - if (doAction() == true) { - clearAccessInput(); - mytop.pmsetdefaultpLabel(); - frame.setVisible(false); - frame.repaint(); - // frame.dispose(); - mytop.scrollPane.revalidate(); - mytop.scrollPane.repaint(); - } else { - Debug.message("CLNT: pmAccess: doAction is false"); - } - - } - - public void actionapplyButton() { - Debug.message("CLNT:pmAccess:actionapplyButton()"); - - if (doAction() == true) { - mytop.pmsetdefaultpLabel(); - mytop.scrollPane.revalidate(); - mytop.scrollPane.repaint(); - - } - } - - - public void actionresetButton() { - Debug.message("CLNT:pmAccess:actionresetButton()"); - clearAccessInput(); - pnameText.requestFocus(); - } - - public void actioncancelButton() { - Debug.message("CLNT:pmAccess:actioncancelButton()"); - clearAccessInput(); - frame.setVisible(false); - frame.repaint(); - // frame.dispose(); - } - - public void actionhelpButton() { - Debug.message("CLNT:pmAccess:actionhelpButton()"); - mytop.showHelpItem("AddAccess"); - } - - - public void Show() { - - frame.getContentPane().add("North", this); - frame.pack(); - frame.setVisible(true); - frame.repaint(); - - frame.toFront(); - frame.requestFocus(); - - okButton.setAsDefaultButton(); - pnameText.requestFocus(); - Debug.message("CLNT:pmAccess:Show()"); - - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAddAccessFailedException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAddAccessFailedException.java deleted file mode 100644 index 40899aaf91..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAddAccessFailedException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmAddAccessFailedException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmAddAccessFailedException extends pmGuiException { - public pmAddAccessFailedException(String s) { - super(s); - } - public pmAddAccessFailedException() { - super(); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAddPrinterFailedException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAddPrinterFailedException.java deleted file mode 100644 index c952484b08..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAddPrinterFailedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmAddPrinterFailedException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmAddPrinterFailedException extends pmGuiException { - public pmAddPrinterFailedException(String s) { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAuthOptions.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAuthOptions.java deleted file mode 100644 index 456fd87850..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmAuthOptions.java +++ /dev/null @@ -1,423 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmAuthOptions.java - * Prompt for root password from printmgr. - * This a helper for printmgr which echoes YES, NO, or CANCEL to stdout. - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.*; -import com.sun.admin.pm.server.*; - - -public class pmAuthOptions { - - public static void main(String[] args) { - - boolean done = false; - String rv = "CANCEL"; - - pmAuthMessage o = new pmAuthMessage(null, - pmUtility.getResource("Authentication.required"), - pmUtility.getResource("Root.access.is.required")); - o.setVisible(true); - switch (o.getValue()) { - case JOptionPane.YES_OPTION: - break; - - case JOptionPane.NO_OPTION: - System.out.println("NO"); - System.exit(0); - break; - - case JOptionPane.CANCEL_OPTION: - default: - System.out.println("CANCEL"); - System.exit(0); - break; - } - - while (!done) { - pmAuthLogin d = new pmAuthLogin(null, - pmUtility.getResource("Root.authentication"), - pmUtility.getResource("Enter.root.password")); - d.setVisible(true); - if (d.getValue() != JOptionPane.OK_OPTION) - done = true; - else { - boolean ok = false; - String pw = new String(d.getPassword()); - try { - PrinterUtil.checkRootPasswd(pw); - ok = true; - } catch (Exception x) { - - } - if (!ok) { - pmOKCancelDialog m = new pmOKCancelDialog(null, - pmUtility.getResource("Error"), - pmUtility.getResource("Invalid.password")); - m.setVisible(true); - if (m.getValue() != JOptionPane.OK_OPTION) - done = true; - } else { - done = true; - rv = "YES"; - } - } - } - - System.out.println(rv); - System.exit(0); - } - - -} - - -/* - */ - -class pmAuthLogin extends pmDialog { - private String theTag = null; - - protected pmButton okButton = null; - protected pmButton cancelButton = null; - - public pmAuthLogin(JFrame f, String title, String msg) { - - super(f, title, true); // modal - - JLabel l; - JPanel p; - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.EAST; - - // top panel contains the desired message - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - l = new JLabel(msg, SwingConstants.CENTER); - p.add(l, c); - this.getContentPane().add(p, "North"); - - - // middle panel contains username and password - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - l = new JLabel(pmUtility.getResource("Hostname:"), - SwingConstants.RIGHT); - p.add(l, c); - - l = new JLabel(pmUtility.getResource("Password:"), - SwingConstants.RIGHT); - p.add(l, c); - - passwordField = new JPasswordField(12); - passwordField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okPressed(); - } - }); - l.setLabelFor(passwordField); - - // for consistency, don't implement this until all are... - // l.setDisplayedMnemonic( - // pmUtility.getIntResource("Password.mnemonic")); - - c.gridx = 1; - c.weightx = 1.0; - - c.anchor = GridBagConstraints.WEST; - - String hostname = null; - try { - hostname = (java.net.InetAddress.getLocalHost()).getHostName(); - } catch (java.net.UnknownHostException uhx) { - System.out.println(uhx); - } - - l = new JLabel(hostname, SwingConstants.LEFT); - p.add(l, c); - - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.gridy = GridBagConstraints.RELATIVE; - - p.add(passwordField, c); - passwordField.setEchoChar('*'); - - this.getContentPane().add(p, "Center"); - - // bottom panel contains buttons - c.gridx = 0; - c.weightx = 1.0; - c.weighty = 0.0; - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - - JPanel thePanel = new JPanel(); - - okButton = new pmButton( - pmUtility.getResource("OK")); - okButton.setMnemonic( - pmUtility.getIntResource("OK.mnemonic")); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okPressed(); - } - }); - thePanel.add(okButton, c); - - cancelButton = new pmButton( - pmUtility.getResource("Cancel")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Cancel.mnemonic")); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelPressed(); - } - }); - thePanel.add(cancelButton, c); - - this.getContentPane().add(thePanel, "South"); - - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - returnValue = JOptionPane.CANCEL_OPTION; - setVisible(false); - } - }); - - // handle Esc as cancel in any case - this.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - cancelPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - // lay out the dialog - this.pack(); - - // set focus and defaults after packing... - // this.getRootPane().setDefaultButton(okButton); - okButton.setAsDefaultButton(); - - passwordField.requestFocus(); - } - - public int getValue() { - return returnValue; - } - - - public void okPressed() { - returnValue = JOptionPane.OK_OPTION; - setVisible(false); - } - - public void cancelPressed() { - returnValue = JOptionPane.CANCEL_OPTION; - setVisible(false); - } - - - public void clearPressed() { - passwordField.setText(""); - } - - public char[] getPassword() { - return passwordField.getPassword(); - } - - - public JPasswordField passwordField = null; - - protected int returnValue = JOptionPane.CANCEL_OPTION; - -} - - -class pmAuthMessage extends pmDialog { - private String theTag = null; - - protected pmButton authButton = null; - protected pmButton cancelButton = null; - protected pmButton contButton = null; - - public pmAuthMessage(JFrame f, String title, String msg) { - - super(f, title, true); // modal - - JPanel p; - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.EAST; - - // top panel contains the desired message - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - - JList l = new JList() { - public boolean isFocusable() { - return false; - } - }; - // pathetic hacks to make the list look the same as a label - JLabel tmp = new JLabel(); - l.setBackground(tmp.getBackground()); - l.setForeground(tmp.getForeground()); - l.setFont(tmp.getFont()); - tmp = null; - Vector v = new Vector(); - if (msg != null) { - StringTokenizer st = new StringTokenizer(msg, "\n", false); - try { - while (st.hasMoreTokens()) - v.addElement(st.nextToken()); - } catch (Exception x) { - } - l.setListData(v); - } - - - p.add(l, c); - this.getContentPane().add(p, "North"); - - - // bottom panel contains buttons - c.gridx = 0; - c.weightx = 1.0; - c.weighty = 0.0; - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - - JPanel thePanel = new JPanel(); - - authButton = new pmButton(pmUtility.getResource("Authenticate")); - authButton.setMnemonic( - pmUtility.getIntResource("Authenticate.mnemonic")); - authButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - authPressed(); - } - }); - thePanel.add(authButton, c); - - contButton = new pmButton(pmUtility.getResource("Continue")); - contButton.setMnemonic(pmUtility.getIntResource("Continue.mnemonic")); - contButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - contPressed(); - } - }); - thePanel.add(contButton, c); - - cancelButton = new pmButton(pmUtility.getResource("Cancel")); - cancelButton.setMnemonic(pmUtility.getIntResource("Cancel.mnemonic")); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelPressed(); - } - }); - thePanel.add(cancelButton, c); - - this.getContentPane().add(thePanel, "South"); - - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - returnValue = JOptionPane.CANCEL_OPTION; - setVisible(false); - } - }); - - // handle Esc as cancel in any case - this.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - cancelPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - // lay out the dialog - this.pack(); - - // set focus and defaults after packing... - authButton.setAsDefaultButton(); - - } - - public int getValue() { - return returnValue; - } - - - public void authPressed() { - returnValue = JOptionPane.YES_OPTION; - setVisible(false); - } - - public void cancelPressed() { - returnValue = JOptionPane.CANCEL_OPTION; - setVisible(false); - } - - - public void contPressed() { - returnValue = JOptionPane.NO_OPTION; - setVisible(false); - } - - protected int returnValue = JOptionPane.CANCEL_OPTION; - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmButton.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmButton.java deleted file mode 100644 index 1c14c5642e..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmButton.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmButton.java - * - */ - -package com.sun.admin.pm.client; - -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - -/* - * strategy: - * Keep a hashtable of root panes and their associated default buttons. - * Note that there is at present no way to remove a root pane entry - * from the table... - * - * Ideally there should be an interface to allow objects to - * remove themselves before disappearing. - */ - -public class pmButton extends JButton { - - // static JButton defaultButton = null; - - // map root panes to their true default buttons - static Hashtable map = new Hashtable(); - - public static Hashtable getHashtable() { - return map; - } - - /* - * make this button the default on this root pane - * retunrs true if success, false o/w - */ - boolean makeDefaultButton() { - return makeDefaultButton(this); - } - - /* - * make b the default on this root pane - * returns true if success, false otherwise - */ - boolean makeDefaultButton(JButton b) { - JRootPane r = this.getRootPane(); - - if (r == null) { - Debug.info("BUTTON: null root panel"); - return false; - } - - if (b == null) { - Debug.info("BUTTON: makeDefaultButton null on " + r); - } - - /* - * Debug.info("\nBUTTON: makeDefaultButton " + - * (b == null ? "null" : b.getText()) + - * " on " + r + "\n"); - */ - - if (b != null && b.isDefaultCapable() == false) { - Debug.info("BUTTON: false isDefaultCapable on " + r); - return false; - } - - // unfocus the old default, if it's different - JButton oldb; - if ((oldb = r.getDefaultButton()) != null && oldb != b) { - oldb.setFocusPainted(false); - } - - /* - * Debug.info("\nBUTTON: makeDefaultButton: old button was " + - * (oldb == null ? "null" : oldb.getText()) + "\n"); - */ - - r.setDefaultButton(b); - - return true; - } - - - public pmButton(String s) { - super(s); - - this.addFocusListener(new FocusAdapter() { - - // upon gaining focus: make this the root pane's default - public void focusGained(FocusEvent e) { - if (e.isTemporary()) { - /* - * Debug.info("BUTTON: " + getText() + - * " gained temp - ignoring"); - */ - return; - } - - Debug.info("BUTTON: " + getText() + " gained"); - - if (makeDefaultButton()) - setFocusPainted(true); - - } - - // upon losing focus: make 'true' default the default - public void focusLost(FocusEvent e) { - if (e.isTemporary()) { - /* - * Debug.info("BUTTON: " + getText() + - * " lost temp - ignoring"); - */ - return; - } - - Debug.info("BUTTON: " + getText() + " lost"); - - /* - * i thought it might make sense to test for the - * next focusable comp, but what if focus is being - * lost as the result of a mouse click?? - */ - - makeDefaultButton((JButton) map.get(getRootPane())); - // setFocusPainted(false); - } - - }); - } - - // make this the true default for this root pane - void setAsDefaultButton() { - setAsDefaultButton(this); - } - - // make b the true default for this root pane - void setAsDefaultButton(JButton b) { - JRootPane r = getRootPane(); - - /* - * Debug.message("BUTTON: setAsDefaultButton " + - * (b == null ? "null" : b.getText()) + - * " root = " + r); - */ - - // setting default to null removes state - if (b == null) - map.remove(r); - else - map.put(r, b); // creates a new entry if needed - makeDefaultButton(b); - } - - - // clean up component about to be removed - void unreference() { - JRootPane r = getRootPane(); - map.remove(r); - } - - public static void unreference(JComponent c) { - JRootPane r = c.getRootPane(); - map.remove(r); - } - - public static void unreference(JRootPane r) { - map.remove(r); - } - - - static boolean enableMnemonics = false; - - static void setEnableMnemonics(boolean m) { - enableMnemonics = m; - } - - public void setMnemonic(int mnemonic) { - setMnemonic((char)mnemonic); - } - - public void setMnemonic(char mnemonic) { - if (enableMnemonics) - super.setMnemonic(mnemonic); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmButtonScreen.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmButtonScreen.java deleted file mode 100644 index de18335be2..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmButtonScreen.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmButtonsScreen.java - * Common dialog superclass - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * Screen class for JPanels - */ - -public class pmButtonScreen extends JPanel { - - final static int OK = 1; - final static int APPLY = 2; - final static int RESET = 3; - final static int CANCEL = 4; - final static int HELP = 5; - - pmButton okButton; - pmButton applyButton; - pmButton resetButton; - pmButton cancelButton; - pmButton helpButton; - - - public void southPanel() { - - JPanel south = new JPanel(); - - south.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.gridheight = 1; - c.gridwidth = 1; - c.weightx = c.weighty = 0.0; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridy = 0; - - okButton = new pmButton( - pmUtility.getResource("OK")); - okButton.setMnemonic( - pmUtility.getIntResource("OK.mnemonic")); - - applyButton = new pmButton( - pmUtility.getResource("Apply")); - applyButton.setMnemonic( - pmUtility.getIntResource("Apply.mnemonic")); - - resetButton = new pmButton( - pmUtility.getResource("Reset")); - resetButton.setMnemonic( - pmUtility.getIntResource("Reset.mnemonic")); - - cancelButton = new pmButton( - pmUtility.getResource("Cancel")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Cancel.mnemonic")); - - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - - okButton.addActionListener(new ButtonListener(OK)); - applyButton.addActionListener(new ButtonListener(APPLY)); - resetButton.addActionListener(new ButtonListener(RESET)); - cancelButton.addActionListener(new ButtonListener(CANCEL)); - helpButton.addActionListener(new ButtonListener(HELP)); - - c.insets = new Insets(15, 5, 10, 5); - c.gridx = 0; - south.add(okButton, c); - c.gridx = 1; - south.add(applyButton, c); - c.gridx = 2; - south.add(resetButton, c); - c.gridx = 3; - south.add(cancelButton, c); - c.gridx = 4; - south.add(helpButton, c); - - add("South", south); - } - - class ButtonListener implements ActionListener { - int activeButton; - - // Constructor - - public ButtonListener(int aButton) - { - activeButton = aButton; - } - - public void actionPerformed(ActionEvent e) - { - switch (activeButton) { - case OK: - actionokButton(); - break; - case APPLY: - actionapplyButton(); - break; - case RESET: - actionresetButton(); - break; - case CANCEL: - actioncancelButton(); - break; - case HELP: - actionhelpButton(); - break; - } - } - } - - public void actionokButton() - { - } - - public void actionapplyButton() - { - } - - public void actionresetButton() - { - } - - public void actioncancelButton() - { - } - - public void actionhelpButton() - { - } - - - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmCacheMissingPPDException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmCacheMissingPPDException.java deleted file mode 100644 index 4a2b171f68..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmCacheMissingPPDException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmInstallPrinter.java - * Install and Modify Printer implementation - * - * pmCacheMissingPPDException - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -public class pmCacheMissingPPDException extends pmGuiException { - public pmCacheMissingPPDException(String s) { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmCalls.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmCalls.java deleted file mode 100644 index 5503d90a97..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmCalls.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmCalls.java - * Debug messages - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.applet.*; -import java.io.*; -import java.util.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * Class of calls to backend - */ - -public class pmCalls { - -/* - * Debugging routines - */ - - public static void testout(String out) { - Debug.info(out); - } - - public static void debugShowPrinter(Printer p) { - Debug.info("CLNT: debugShowPrinter"); - - if (p.getPrinterName() != null) { - Debug.info("CLNT: printer " + - p.getPrinterName()); - } - - if (p.getPrintServer() != null) - Debug.info("CLNT: server " + - p.getPrintServer()); - - if (p.getPrinterType() != null) - Debug.info("CLNT: printer type " + - p.getPrinterType()); - - if (p.getComment() != null) - Debug.info("CLNT: Comment " + - p.getComment()); - - if (p.getDevice() != null) - Debug.info("CLNT: Device " + - p.getDevice()); - - if (p.getMake() != null) - Debug.info("CLNT: Make " + - p.getMake()); - else - Debug.info("CLNT: Make is null"); - - if (p.getModel() != null) - Debug.info("CLNT: Model " + - p.getModel()); - else - Debug.info("CLNT: Model is null"); - - if (p.getPPD() != null) - Debug.info("CLNT: PPD " + - p.getPPD()); - else - Debug.info("CLNT: PPD is null"); - - if (p.getNotify() != null) - Debug.info("CLNT: Notify " + - p.getNotify()); - - if (p.getBanner() != null) - Debug.info("CLNT: Banner " + p.getBanner()); - - if (p.getProtocol() != null) - Debug.info("CLNT: Protocol " + - p.getProtocol()); - - if (p.getDestination() != null) - Debug.info("CLNT: Destination " + - p.getDestination()); - - if (p.getFileContents() != null) { - - String filedata[] = p.getFileContents(); - String filecontents = new String(); - - Debug.info("CLNT: File Contents: "); - - if (filedata != null) { - for (int i = 0; i < filedata.length; i++) { - Debug.info(" " + filedata[i]); - } - } - } - - if (p.getNotify() != null) { - Debug.info("CLNT: Fault Notification: " + p.getNotify()); - } - - String ua[] = p.getUserAllowList(); - Debug.info("CLNT: UserAllowList "); - if (ua != null) { - for (int i = 0; i < ua.length; i++) { - Debug.info(" " + ua[i]); - } - } - - Debug.info("CLNT: getIsDefaultPrinter is " + p.getIsDefaultPrinter()); - - } - - public static void debugshowPrinterList(NameService ns) { - - String[] list; - - try { - list = PrinterUtil.getPrinterList(ns); - for (int i = 0; i < list.length; i++) - Debug.info("CLNT: " + list[i]); - } catch (Exception e) { - Debug.info("CLNT: debugshowPrinterList(): exception " + e); - } - - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDelete.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDelete.java deleted file mode 100644 index 4e138209b8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDelete.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmDelete.java - * Delete Printer implementation - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * Window for Edit -> Delete - */ - -// public class pmDelete extends JPanel { -public class pmDelete { - - Printer newpr = null; - pmTop mytop = null; - - public pmDelete(pmTop mytop) - { - this.mytop = mytop; - newpr = new Printer(mytop.ns); - - Debug.message("CLNT: pmDelete"); - - if (mytop.selectedPrinter.equals("")) { - Debug.warning("CLNT: pmDelete:error: selectedPrinter empty"); - // Display error window - actioncancelButton(); - } - - pmOKCancelDialog d = new pmOKCancelDialog( - mytop.parentFrame, - pmUtility.getResource("SPM:Delete.Printer"), - pmUtility.getResource("Please.confirm.deletion.of.printer") + - mytop.selectedPrinter, false); - d.setVisible(true); - - if (d.getValue() != JOptionPane.OK_OPTION) - actioncancelButton(); - else { - try { - actionokButton(); - } catch (pmUserCancelledException ce) { - Debug.message("CLNT: pmDelete:okButton: Login cancelled"); - } catch (pmLoginFailedException de) { - pmMessageDialog m = new pmMessageDialog( - mytop.parentFrame, - pmUtility.getResource("Error"), - pmUtility.getResource("Required.login.failed."), - mytop, - "LoginFailed"); - m.setVisible(true); - } catch (pmGuiException ge) { - pmMessageDialog m = new pmMessageDialog( - mytop.parentFrame, - pmUtility.getResource("Application.Error"), - ge.toString()); - m.setVisible(true); - } - } - - } - - public void actionokButton() throws pmGuiException { - int ret; - String cmd = null; - String warn = null; - String err = null; - - Debug.message("CLNT: pmDelete actionokButton()"); - - // handle authentication if needed - if (mytop.ns.getNameService().equals("nis") == true || - mytop.ns.getNameService().equals("ldap") == true) { - try { - if (!mytop.ns.isAuth()) { - pmUtility.doLogin(mytop, mytop.parentFrame); - } - } catch (pmUserCancelledException e) { - Debug.message("CLNT: pmDelete:User cancelled login"); - throw new pmUserCancelledException( - pmUtility.getResource("User.Cancelled.Login")); - } catch (pmGuiException e) { - Debug.warning("CLNT: pmDelete:login for nis/ldap failed"); - throw new pmLoginFailedException( - pmUtility.getResource("Login.Authorization.Failed")); - } catch (Exception e) { - Debug.warning("CLNT: pmDelete:login for nis/ldap failed"); - throw new pmLoginFailedException( - pmUtility.getResource("Login.Authorization.Failed")); - } - } - - newpr.setPrinterName(mytop.selectedPrinter); - - // delete the printer - boolean failed = false; - try { - newpr.deletePrinter(); - } catch (Exception e) { - Debug.warning("CLNT: pmDelete:deletePrinter exception " + e); - failed = true; - } - - cmd = newpr.getCmdLog(); - warn = newpr.getWarnLog(); - err = newpr.getErrorLog(); - - Debug.message("CLNT: pmDelete: delete cmd = " + cmd); - Debug.message("CLNT: pmDelete: delete err = " + err); - Debug.message("CLNT: pmDelete: delete warn = " + warn); - - if (failed) { - pmMessageDialog m = new pmMessageDialog( - mytop.parentFrame, - pmUtility.getResource("Error"), - ((err == null) ? - pmUtility.getResource( - "Printer.delete.operation.failed.") : - err), - mytop, - "DeletePrinterFailed"); - m.setVisible(true); - - } else { - Debug.message("CLNT: pmDelete return from deletePrinter ok"); - - // Deletion successful, change the table - if (mytop.selectedRow >= 0) { - // update table - mytop.pmsetPrinterList(); - mytop.clearSelected(); - mytop.listTable.clearSelection(); - mytop.pmsetdefaultpLabel(); - } else { - Debug.warning("CLNT: pmDelete:selectedRow invalid: " + - mytop.selectedRow); - } - } - mytop.setLogData(cmd, err, warn); - mytop.showLogData(pmUtility.getResource("Delete.Printer")); - } - - - public void actioncancelButton() { - Debug.message("CLNT: pmDelete: actioncancelButton()"); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDeleteFailedException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDeleteFailedException.java deleted file mode 100644 index 88237fd948..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDeleteFailedException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmDeleteFailedException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmDeleteFailedException extends pmGuiException { - public pmDeleteFailedException(String s) { - super(s); - } - public pmDeleteFailedException() { - super(); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDialog.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDialog.java deleted file mode 100644 index 87a9adbdf8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDialog.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmDialog.java - * Extends JDialog to provide for better default location. - */ - -package com.sun.admin.pm.client; - -import java.net.*; -import java.awt.*; -import javax.swing.*; -import java.awt.event.*; - -import com.sun.admin.pm.server.Debug; - -public class pmDialog extends JDialog implements pmDialogConstraints { - - public pmDialog(Frame owner) { - this(owner, null, false); - } - - public pmDialog(Frame owner, boolean modal) { - this(owner, null, modal); - } - - public pmDialog(Frame owner, String title) { - this(owner, title, false); - } - - public pmDialog(Frame f, String title, boolean modal) { - - super(f, title, modal); - - // determine a nice location relative to parent frame - Point newLocation = new Point(0, 0); // default - - if (f == null) { - // centered on screen - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - newLocation = new Point(screenSize.width / 2 - xoffset, - screenSize.height / 2 - yoffset); - - } else { - // centered over parent frame - Rectangle parentBounds = f.getBounds(); - newLocation = new Point( - parentBounds.x + parentBounds.width / 2 - xoffset, - parentBounds.y + parentBounds.height / 2 - yoffset); - f.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - Debug.info("dialog Window closing"); - cleanupButtons(); - } - public void windowClosed(WindowEvent e) { - Debug.info("dialog Window closed"); - cleanupButtons(); - } - public void windowDeactivated(WindowEvent e) { - Debug.info("dialog Window deactivated"); - // possible java bug: too many of these events generated! - // cleanupButtons(); - } - }); - } - setLocation(newLocation); - - // cannot set dialog icons under 1.1.... - /* - * try { - * String iconName = new String("images/appicon.gif"); - * Class thisClass = this.getClass(); - * URL iconUrl = thisClass.getResource(iconName); - * if (iconUrl == null) - * Debug.warning("Unable to resolve URL for icon " + iconName); - * else { - * Toolkit tk = Toolkit.getDefaultToolkit(); - * Image img = tk.getImage(iconUrl); - * // this.setIconImage(img); - * } - * } catch (Exception x) { - * Debug.warning(x.toString()); - * } - */ - - } - - public void cleanupButtons() { - // drop this rootPane from pmButton's hashtable - pmButton.unreference(this.getRootPane()); - } - - public void setVisible(boolean b) { - if (b == false) - cleanupButtons(); - super.setVisible(b); - } - -} - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDialogConstraints.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDialogConstraints.java deleted file mode 100644 index f7a90727c1..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmDialogConstraints.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmDialogConstraints.java - * Location constants for pmDialogs. - */ - -package com.sun.admin.pm.client; - -public interface pmDialogConstraints { - - /* - * These are offsets from origin of a pmDialog's parent frame - * at which to place the newly created dialog. - */ - static final int xoffset = 100; - static final int yoffset = 80; -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmFindFrame.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmFindFrame.java deleted file mode 100644 index ad54f0a6b8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmFindFrame.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmFindFrame.java - * Find Printer dialog implementation - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -public class pmFindFrame extends pmFrame { - - JLabel statusText = null; - pmButton okButton = null; - pmButton cancelButton = null; - pmButton helpButton = null; - pmTop theTop = null; - - String label = pmUtility.getResource("Enter.name.of.printer.to.find"); - String helpTag = "ToFindPrinter"; - - public pmFindFrame(pmTop t) { - - super(pmUtility.getResource("SPM:Find.Printer")); - - setLocation(100, 100); - - theTop = t; - - - JLabel l; - JPanel p; - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 5, 10); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1.0; - - // top panel contains the message - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - l = new JLabel(label, SwingConstants.LEFT); - p.add(l, c); - - getContentPane().add(p, "North"); - - // middle panel contains "other" text field - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - printerName = new pmTextField(30); - printerName.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okPressed(); - } - }); - l.setLabelFor(printerName); - - c.gridx = 1; - c.gridy = 0; - c.weightx = 1.0; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = new Insets(0, 10, 5, 10); - - p.add(printerName, c); - - statusText = new JLabel(" ", SwingConstants.LEFT); - - c.gridy = GridBagConstraints.RELATIVE; - c.gridx = 0; - c.gridwidth = 2; - - c.insets = new Insets(5, 10, 5, 10); - p.add(statusText, c); - - getContentPane().add(p, "Center"); - - // bottom panel contains buttons - c.gridx = 0; - c.weightx = 1.0; - c.weighty = 0.0; - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = new Insets(5, 10, 10, 10); - - JPanel thePanel = new JPanel(); - - okButton = new pmButton( - pmUtility.getResource("Find")); - okButton.setMnemonic( - pmUtility.getIntResource("Find.mnemonic")); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okPressed(); - } - }); - thePanel.add(okButton, c); - - cancelButton = new pmButton( - pmUtility.getResource("Dismiss")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Dismiss.mnemonic")); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelPressed(); - } - }); - thePanel.add(cancelButton, c); - - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - theTop.showHelpItem(helpTag); - } - }); - thePanel.add(helpButton, c); - - getContentPane().add(thePanel, "South"); - - // lay out the dialog - pack(); - - // handle Esc as dismiss in any case - getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - cancelPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - - // set focus to initial field, depending on which action is tbd - // this seems to work best after pack() - - /* - * frame.setVisible(true); - * frame.repaint(); - */ - - // getRootPane().setDefaultButton (okButton); - okButton.setAsDefaultButton(); - - printerName.requestFocus(); - - // enable improved focus handling - setDefaultComponent(printerName); - - } - - - public void okPressed() { - Debug.message("CLNT: pmFindFrame:okPressed():" + - printerName.getText()); - - String name = printerName.getText(); - boolean result = theTop.findPrinterInList(name.trim()); - if (!result) - statusText.setText(new String( - pmUtility.getResource("Unable.to.find.printer") + name)); - else - statusText.setText(" "); - - // pmFindPanel.this.frame.setVisible (false); - - } - - public void cancelPressed() { - Debug.message("CLNT: pmFindFrame: cancelPressed()"); - statusText.setText(" "); - printerName.setText(""); - pmFindFrame.this.setVisible(false); - - } - - public pmTextField printerName = null; - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmFrame.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmFrame.java deleted file mode 100644 index ec37480473..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmFrame.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmFrame.java - * Extends JFrame to support better focus handling - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.net.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - -class pmFrame extends JFrame { - - // this comp gets focus on frame open - Component defaultComponent = null; - - // file path of icon; this does not provide for localization - private static final String iconName = "images/appicon.gif"; - - // if true, clean up pmButton state on frame close - private boolean clearButtonsOnClose; - - public pmFrame(String s) { - super(s); - - // default: do NOT clear default button state when frame is closed - clearButtonsOnClose = false; - - this.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - Debug.message("CLNT: pmFrame focus gained: " + e); - if (defaultComponent != null) { - Debug.message("CLNT: pmFrame focus to default comp"); - defaultComponent.requestFocus(); - } else - Debug.message("CLNT: pmFrame no default comp"); - } - public void focusLost(FocusEvent e) { - Debug.message("CLNT: frame focus lost: " + e); - } - }); - - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - Debug.info("frame Window closing"); - cleanupButtons(); - } - public void windowClosed(WindowEvent e) { - Debug.info("frame Window closed"); - cleanupButtons(); - } - }); - - try { - Class thisClass = this.getClass(); - URL iconUrl = thisClass.getResource(iconName); - // System.out.println("Icon: " + iconUrl); - if (iconUrl == null) - Debug.warning("Unable to resolve URL for icon " + iconName); - else { - Toolkit tk = Toolkit.getDefaultToolkit(); - Image img = tk.getImage(iconUrl); - this.setIconImage(img); - } - - } catch (Exception x) { - Debug.warning(x.toString()); - } - } - - - public void setDefaultComponent(Component c) { - defaultComponent = c; - } - - - // If the frame is a minimized icon, make it un-minimized first - public void setVisible(boolean isVisible) { - if (isVisible == true) { - try { - // this will fail in jdk 1.1 but work fine in 1.2 - setState(NORMAL); - } catch (Exception ssx) { - // restores an iconified window in JDK 1.1 - removeNotify(); - addNotify(); - } - } else - cleanupButtons(); - super.setVisible(isVisible); - } - - public void cleanupButtons() { - // drop this rootPane from pmButton's hashtable - if (clearButtonsOnClose) - pmButton.unreference(this.getRootPane()); - } - - protected void setClearButtonsOnClose(boolean b) { - clearButtonsOnClose = b; - } - - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmGuiException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmGuiException.java deleted file mode 100644 index f4dfccae58..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmGuiException.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmGuiException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -public class pmGuiException extends Exception { - - String s = null; - - public pmGuiException(String s) { - super(s); - - } - - public pmGuiException() { - super(); - - } - -// XXX use localized strings - public String getLocalizedMessage() { - return getMessage(); - - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpContent.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpContent.java deleted file mode 100644 index 27919cbde5..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpContent.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpContent.java - * Wrapper for content of help articles - */ - -package com.sun.admin.pm.client; - -class pmHelpContent extends Object { - private String text; - - public pmHelpContent(String content) { - text = content; - } - - public pmHelpContent(pmHelpContent other) { - text = new String(other.text); - } - - public String toString() { - return text; - } - - public String getText() { - return text; - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpController.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpController.java deleted file mode 100644 index 320d470254..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpController.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpController.java - * Help subsystem implementation - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.io.*; -import javax.swing.JPanel; -import javax.swing.border.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - -class pmHelpController { - - public pmHelpFrame frame = null; - - /* - * request presentation of the specified help item. - */ - public void showHelpItem(String tag) { - Debug.info("HELP: controller.showHelpitem " + tag); - if (tag != null) { - pmHelpItem item = viewPanel.loadItemForTag(tag); - outerPanel.setSelectedComponent(viewPanel); - } - } - - public void showHelpItem(pmHelpItem item) { - if (item != null) - showHelpItem(item.tag); - } - - JTabbedPane outerPanel; - pmHelpDetailPanel viewPanel; - pmHelpIndexPanel indexPanel; - pmHelpSearchPanel searchPanel; - - Vector history; - - public JTabbedPane getTopPane() { - return outerPanel; - } - - public pmHelpController(pmHelpFrame f) { - - frame = f; - - outerPanel = new JTabbedPane(); - - viewPanel = new pmHelpDetailPanel(this); - indexPanel = new pmHelpIndexPanel(this); - searchPanel = new pmHelpSearchPanel(this); - - outerPanel.add(pmUtility.getResource("View"), viewPanel); - outerPanel.add(pmUtility.getResource("Index"), indexPanel); - outerPanel.add(pmUtility.getResource("Search"), searchPanel); - - pmHelpRepository.populateHelpItemDB(); - pmHelpRepository.populateHelpKeywordDB(); - pmHelpRepository.populateHelpTitleDB(); - - indexPanel.queryPanel.handleText(""); // prime it... ugly. - - history = new Vector(); - - frame.setDefaultComponent(outerPanel); - } - - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpDetailPanel.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpDetailPanel.java deleted file mode 100644 index 434670f508..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpDetailPanel.java +++ /dev/null @@ -1,597 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 - 2001 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpDetailPanel.java - * View a help article - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.io.*; -import java.net.URL; -import javax.swing.JPanel; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - -class pmHelpLoc { - public pmHelpItem item; - public Point pos; - - public pmHelpLoc(pmHelpItem i) { - this(i, new Point(0, 0)); - } - - public pmHelpLoc(pmHelpItem i, Point p) { - item = i; - pos = p; - } - - public pmHelpLoc() { - this(null, new Point(0, 0)); - } -} - -public class pmHelpDetailPanel extends JPanel { - - pmHelpController controller; - pmHelpSeeAlsoPanel seeAlsoPanel; - pmHelpViewPanel viewPanel; - - pmHelpLoc history[]; - int historyIndex; - int historyLast; - - static final int MAX_HISTORY_ITEMS = 101; - - public pmHelpDetailPanel(pmHelpController ctrl) { - - controller = ctrl; - - // build subpanels - seeAlsoPanel = new pmHelpSeeAlsoPanel(this); - viewPanel = new pmHelpViewPanel(this); - - // lay out top panel - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.insets = new Insets(5, 5, 5, 5); - - c.gridwidth = GridBagConstraints.REMAINDER; - - c.gridx = 0; - c.gridy = 0; - - c.gridheight = 2; // GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1.0; - c.weighty = 6.0; - c.insets = new Insets(5, 5, 0, 5); - this.add(viewPanel, c); - - c.gridy = GridBagConstraints.RELATIVE; - // c.gridheight = GridBagConstraints.REMAINDER; - c.gridheight = 0; - c.weighty = 0.0; - c.weightx = 1.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.WEST; - c.insets = new Insets(0, 5, 5, 5); - this.add(seeAlsoPanel, c); - - this.setBorder(BorderFactory.createEtchedBorder()); - - history = new pmHelpLoc[MAX_HISTORY_ITEMS]; - historyIndex = 0; - historyLast = 0; - - // manage focus when we are tabbed or un-tabbed - controller.outerPanel.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - JTabbedPane tp = (JTabbedPane) e.getSource(); - Debug.info("HELP: Tab event!"); - if (!(tp.getSelectedComponent() instanceof - com.sun.admin.pm.client.pmHelpDetailPanel)) { - Debug.info("HELP: Tab event: resetting default"); - /* - * controller.frame.getRootPane(). - * setDefaultButton( - * controller.frame.dismiss); - */ - if (controller.frame.dismiss != null) - controller.frame.dismiss. - setAsDefaultButton(); - } - } - }); - - addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - Debug.info("HELP: detailPanel gained focus"); - if (controller.frame.dismiss != null) - controller.frame.dismiss. - setAsDefaultButton(); - - } - }); - } - - // ask parent controller to show item - public void showItem(String tag) { - controller.showHelpItem(tag); - } - - public void showHistoryBackItem() { - Debug.message("HELP: showHistoryBackItem: index = " + - historyIndex + " last = " + - historyLast + - "\n\thistory = " + - history); - - // assuming item already visible, preserve its position - history[historyIndex].pos = viewPanel.getPos(); - - Debug.info("back: pos is " + history[historyIndex].pos); - - if (historyIndex > 1) { - pmHelpLoc l = history [--historyIndex]; - pmHelpItem item = l.item; - Point p = l.pos; - loadItem(item, p); - } - viewPanel.setNavButtons(historyIndex, historyLast); - } - - public void showHistoryForwardItem() { - Debug.message("HELP: showHistoryForwardItem: index = " + - historyIndex + - " last = " + historyLast + - "\n\thistory = " + history); - - // assuming already an item visible, preserve its position - history[historyIndex].pos = viewPanel.getPos(); - - Debug.info("HELP: fwd: pos is " + history[historyIndex].pos); - - if (historyIndex < historyLast) { - pmHelpLoc l = history [++historyIndex]; - pmHelpItem item = l.item; - Point p = l.pos; - loadItem(item, p); - } - viewPanel.setNavButtons(historyIndex, historyLast); - } - - - /* - * load the help item - * internal - */ - protected pmHelpItem loadItem(pmHelpItem item) { - return loadItem(item, new Point(0, 0)); - } - - protected pmHelpItem loadItem(pmHelpItem item, Point pos) { - Debug.message("HELP: View: loadItem " + item.tag); - seeAlsoPanel.setItems(item.seealso); - - Debug.info("loadItem: pos is " + pos); - - viewPanel.setItem(item.title, item.content); - viewPanel.setPos(pos); - return item; - } - - - /* - * load the help item corresponding to the specified tag - * external - called from helpController - * note that this is how see-also items are loadedes - */ - public pmHelpItem loadItemForTag(String tag) { - - pmHelpItem item; - - if (tag == null || - (item = pmHelpRepository.helpItemForTag(tag)) == null) { - Debug.warning("HELP: View: item not found"); - loadEmptyItem(tag); - return null; - } - - Debug.info("loadItem(before): index = " + historyIndex + - ", last = " + historyLast); - - // if there's already an item visible, preserve its position - if (historyIndex != 0 && historyLast != 0) - history[historyIndex].pos = viewPanel.getPos(); - - loadItem(item); - - Debug.info("HELP: loadItemForTag: index = " + historyIndex + - " last = " + historyLast + "\n\thistory = " + - history); - - /* - * make the new item the latest in history. - * if the history length is maxed out, the new item - * will replace the item that's currently last. - */ - - if (historyIndex < history.length - 1) { - // init pos to 0,0 - history [++historyIndex] = new pmHelpLoc(item); - } else { - // replace last item - history [historyIndex] = new pmHelpLoc(item); - } - historyLast = historyIndex; - - viewPanel.setNavButtons(historyIndex, historyLast); - - Debug.info("loadItem(after): index = " + historyIndex + - ", last = " + historyLast); - return item; - } - - private void loadEmptyItem(String itm) { - String msg = new String( - pmUtility.getResource("Item.not.found:") + itm); - viewPanel.setItem(msg, new pmHelpContent( - pmUtility.getResource("No.information.available."))); - seeAlsoPanel.setItems(null); - } - -} - - - -class pmHelpSeeAlsoPanel extends JPanel { - - pmHelpDetailPanel parentPanel = null; - Vector seeAlsoItems = null; - JComboBox theComboBox = null; - pmButton selectButton = null; - - private void layoutBox() { - - JPanel p = new JPanel(); - p.setLayout(new BorderLayout(5, 0)); - - p.add(new JPanel(), "North"); - p.add(new JPanel(), "South"); - - p.add(new JLabel( - pmUtility.getResource("See.also:")), "West"); - - theComboBox = new JComboBox(); - - Font f = theComboBox.getFont(); - Font fb = new Font(f.getName(), f.PLAIN, f.getSize()); - theComboBox.setFont(fb); - - theComboBox.setPreferredSize( - new Dimension(200, theComboBox.getPreferredSize().height)); - theComboBox.setMinimumSize( - new Dimension(20, theComboBox.getPreferredSize().height)); - theComboBox.setMaximumSize( - new Dimension(300, theComboBox.getPreferredSize().height)); - theComboBox.setEnabled(false); - - /* - * theComboBox.addActionListener(new ActionListener() { - * public void actionPerformed(ActionEvent e) { - * JComboBox src = (JComboBox) e.getSource(); - * System.out.println("Combo: action = " + - * e.getActionCommand()); - * System.out.println("Combo: mod = " + - * e.getModifiers()); - * System.out.println("Combo: param = " + - * e.paramString()); - * System.out.println("Combo: item = " + - * src.getSelectedItem()); - * } - * }); - */ - - p.add(theComboBox, "Center"); - - selectButton = new pmButton( - pmUtility.getResource("Show")); - selectButton.setMnemonic( - pmUtility.getIntResource("Show.mnemonic")); - selectButton.setEnabled(false); - - p.add(selectButton, "East"); - selectButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - pmHelpItem i = (pmHelpItem) theComboBox.getSelectedItem(); - Debug.message("HELP: got button: item is " + i); - // parentPanel.loadItemForTag(i.tag); - parentPanel.showItem(i.tag); - } - }); - - JPanel pp = new JPanel(); - pp.setLayout(new BorderLayout(5, 0)); - pp.add(p, "Center"); - - this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - this.add(Box.createHorizontalStrut(10)); - this.add(pp); - this.add(Box.createHorizontalStrut(10)); - this.add(Box.createHorizontalGlue()); - - } - - public pmHelpSeeAlsoPanel(pmHelpDetailPanel p) { - parentPanel = p; - layoutBox(); - this.setBorder(BorderFactory.createEtchedBorder()); - } - - - /* - * set the titles of the pmHelpItems whose tags are - * passed into see-also combo box - */ - public void setItems(Vector tags) { - clearItems(); - - if (tags == null) - return; - - Enumeration e = tags.elements(); - while (e.hasMoreElements()) { - pmHelpItem i = - pmHelpRepository.helpItemForTag((String) e.nextElement()); - if (i != null) - theComboBox.addItem(i); - } - - selectButton.setEnabled(true); - theComboBox.setEnabled(true); - - - // repaint(); - } - - - public void clearItems() { - if (theComboBox.getItemCount() > 0) - theComboBox.removeAllItems(); - selectButton.setEnabled(false); - theComboBox.setEnabled(false); - } - -} - - -class pmHelpViewPanel extends JPanel { - // JTextArea helpView; - JEditorPane helpView; - JScrollPane scrollPane; - pmHelpHelpOnPanel titlePanel; - pmHelpDetailPanel parentPanel; - pmButton backButton; - pmButton forwardButton; - - public pmHelpViewPanel(pmHelpDetailPanel par) { - parentPanel = par; - - // helpView = new JTextArea(10, 32); - // helpView.setLineWrap(true); - - helpView = new JEditorPane(); - - helpView.setContentType("text/html"); - helpView.setEditable(false); - helpView.setEnabled(false); - helpView.setDisabledTextColor(Color.blue); - - scrollPane = new JScrollPane(helpView); - - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(5, 10, 5, 10); - c.gridwidth = GridBagConstraints.REMAINDER; - - c.gridx = 0; - c.gridy = 0; - - c.gridheight = 1; - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1.0; - // c.weighty = 1.0; - c.weighty = 0.05; - - titlePanel = new pmHelpHelpOnPanel(); - this.add(titlePanel, c); - - c.gridy = 1; - c.gridheight = 1; - - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - c.weighty = 6.0; - c.fill = GridBagConstraints.BOTH; - c.insets = new Insets(5, 10, 5, 10); - // c.insets = new Insets(5, 5, 5, 5); // NEW - this.add(scrollPane, c); - - this.setBorder(BorderFactory.createEtchedBorder()); - - /* - */ - try { - helpView.setPage(new URL("file:///test.html")); - } catch (Exception x) { - Debug.info("setPage caught: " + x); - } - /* - */ - - // navigation buttons - JPanel p = new JPanel(); - p.setLayout(new GridBagLayout()); - GridBagConstraints pc = new GridBagConstraints(); - // pc.insets = new Insets(2, 2, 2, 2); - // pc.fill = GridBagConstraints.HORIZONTAL; - pc.weightx = 1.0; - pc.weighty = 1.0; - pc.gridx = 0; - pc.anchor = GridBagConstraints.WEST; - - backButton = new pmButton( - pmUtility.getResource("Back")); - backButton.setMnemonic( - pmUtility.getIntResource("Back.mnemonic")); - p.add(backButton, pc); - backButton.setEnabled(false); - backButton.setDefaultCapable(false); - backButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - parentPanel.showHistoryBackItem(); - } - }); - - - pc.gridx = 1; - pc.anchor = GridBagConstraints.EAST; - - forwardButton = new pmButton( - pmUtility.getResource("Forward")); - forwardButton.setMnemonic( - pmUtility.getIntResource("Forward.mnemonic")); - p.add(forwardButton, pc); - forwardButton.setEnabled(false); - forwardButton.setDefaultCapable(false); - forwardButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - parentPanel.showHistoryForwardItem(); - } - }); - - c.gridy = GridBagConstraints.RELATIVE; - c.gridheight = 1; // GridBagConstraints.REMAINDER; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - // c.weighty = 1.0; - c.weighty = 0.05; // NEW - - c.fill = GridBagConstraints.BOTH; - c.insets = new Insets(0, 10, 5, 10); - // c.insets = new Insets(0, 10, 5, 10); - c.insets = new Insets(5, 10, 5, 10); - // NEW - - add(p, c); - - } - - - public void setItem(String title, pmHelpContent content) { - helpView.setText(content.getText()); - // scrollPane.getViewport().setViewPosition(new Point(0, 0)); - titlePanel.helpTopic.setText(title); - } - - public void setPos(Point p) { - scrollPane.getViewport().setViewPosition(p); - } - - public Point getPos() { - return scrollPane.getViewport().getViewPosition(); - } - - public void setNavButtons(int index, int last) { - Debug.message("HELP: NavButtons " + index + " " + last); - - if (last > index) - forwardButton.setEnabled(true); - else - forwardButton.setEnabled(false); - - if (index > 1 && last > 1) - backButton.setEnabled(true); - else - backButton.setEnabled(false); - } - -} - - -class pmJTextField extends JTextField { - public boolean isFocusable() { - return false; - } -} - -class pmHelpHelpOnPanel extends JPanel { - - pmJTextField helpTopic; - - public pmHelpHelpOnPanel() { - - helpTopic = new pmJTextField(); - helpTopic.setEditable(false); - helpTopic.setText("Default help topic"); - helpTopic.setBackground(Color.white); - - Font f = helpTopic.getFont(); - Font fb = new Font(f.getName(), Font.BOLD, f.getSize()); - helpTopic.setFont(fb); - - this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - JPanel p = new JPanel(); - p.setLayout(new BorderLayout(5, 0)); - p.add(new JLabel( - pmUtility.getResource("Help.on:")), - "West"); - p.add(helpTopic, "Center"); - - JPanel pp = new JPanel(); - pp.setLayout(new BorderLayout(0, 0)); - pp.add(p, "Center"); - - // this.add(Box.createHorizontalStrut(5)); - this.add(pp); - // this.add(Box.createHorizontalStrut(5)); - this.add(Box.createHorizontalGlue()); - - - // this.setBorder(BorderFactory.createEtchedBorder()); - - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpException.java deleted file mode 100644 index 0079965950..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmHelpException extends Exception { -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpFrame.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpFrame.java deleted file mode 100644 index 094782a99f..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpFrame.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpFrame.java - * Container for help subsystem GUI - */ - -package com.sun.admin.pm.client; - -import java.lang.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.io.*; -import javax.swing.JPanel; -import javax.swing.border.*; -import javax.swing.*; -import com.sun.admin.pm.server.*; - - -public class pmHelpFrame extends pmFrame { - - protected pmHelpController theController = null; - public pmButton dismiss = null; // expose for default button hacks - - public pmHelpFrame() { - super(pmUtility.getResource("SPM:Help")); - - theController = new pmHelpController(this); - getContentPane().add("Center", theController.getTopPane()); - - dismiss = new pmButton( - pmUtility.getResource("Dismiss")); - dismiss.setMnemonic( - pmUtility.getIntResource("Dismiss.mnemonic")); - dismiss.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - hideHelp(); - } - }); - - JPanel p = new JPanel(); - p.add(dismiss); - - getContentPane().add("South", p); - - this.pack(); - this.setVisible(false); - this.repaint(); - - // default button is dismiss - // getRootPane().setDefaultButton(dismiss); - dismiss.setAsDefaultButton(); - - // handle Esc as dismiss - getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("HELP: dismiss action"); - hideHelp(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - } - - - public void hideHelp() { - this.setVisible(false); - } - - - public void showHelp(String tag) { - theController.showHelpItem(tag); - this.setVisible(true); - this.repaint(); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpIndexPanel.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpIndexPanel.java deleted file mode 100644 index f97728cc7a..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpIndexPanel.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpIndexPanel.java - * Search help titles - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.JPanel; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -public class pmHelpIndexPanel extends JPanel { - - pmHelpController controller; - pmHelpIndexQueryPanel queryPanel; - pmHelpIndexResultPanel resultPanel; - JLabel textPanels[]; - - public pmHelpIndexPanel(pmHelpController ctrl) { - controller = ctrl; - - // build subpanels - queryPanel = new pmHelpIndexQueryPanel(this); - resultPanel = new pmHelpIndexResultPanel(this); - - textPanels = new JLabel[4]; - textPanels[0] = new JLabel( - pmUtility.getResource("To.search.the.index...")); - textPanels[1] = new JLabel( - pmUtility.getResource("type.your.query.below...")); - - // lay out top panel - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(5, 5, 5, 5); - c.gridwidth = GridBagConstraints.REMAINDER; - - c.gridx = 0; - c.gridy = 0; - - c.gridheight = 1; // GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1.0; - c.weighty = 0.0; - - JPanel p = new JPanel(); - p.setLayout(new GridBagLayout()); - GridBagConstraints pc = new GridBagConstraints(); - pc.insets = new Insets(5, 5, 0, 5); - // pc.fill = GridBagConstraints.HORIZONTAL; - pc.weightx = 1.0; - pc.anchor = GridBagConstraints.WEST; - pc.gridx = 0; - pc.gridy = GridBagConstraints.RELATIVE; - - p.add(textPanels[0], pc); - pc.insets = new Insets(0, 5, 5, 5); - p.add(textPanels[1], pc); - // p.add(textPanels[2]); - - this.add(p, c); - - p = new JPanel(); - p.setLayout(new BorderLayout()); - p.add(queryPanel, "North"); - p.add(resultPanel, "Center"); - p.setBorder(BorderFactory.createEtchedBorder()); - - c.gridy = GridBagConstraints.RELATIVE; - c.gridheight = 0; - c.weighty = 1.0; - c.weightx = 0.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.EAST; - - this.add(p, c); - - this.setBorder(BorderFactory.createEtchedBorder()); - - - // figure out when we are un-tabbed - controller.outerPanel.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - JTabbedPane tp = (JTabbedPane) e.getSource(); - Debug.info("HELP: Tab event!"); - if (!(tp.getSelectedComponent() instanceof - com.sun.admin.pm.client.pmHelpIndexPanel)) { - Debug.info("HELP: Tab event: resetting default"); - /* - * controller.frame.getRootPane(). - * setDefaultButton( - * controller.frame.dismiss); - */ - } else { - // allow tab to retain focus - // queryPanel.query.requestFocus(); - } - } - }); - - - } - - - // place item titles in search result panel - public void setSearchResults(Vector items) { - Vector v = new Vector(); - - if (items.size() == 0) { - resultPanel.setListEmpty(true); - v.addElement(pmUtility.getResource("Nothing.matched.")); - } else { - Enumeration e = items.elements(); - while (e.hasMoreElements()) { - pmHelpItem i = (pmHelpItem) e.nextElement(); - v.addElement(i); - } - resultPanel.setListEmpty(false); - } - - resultPanel.setResultList(v); - } - -} - - - -class pmHelpIndexResultPanel extends JPanel { - - JList resultList = null; - pmButton selectButton = null; - pmHelpIndexPanel parentPanel = null; - protected boolean listEmpty = true; - - - public pmHelpIndexResultPanel(pmHelpIndexPanel p) { - - parentPanel = p; - - this.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(10, 10, 10, 10); - c.fill = GridBagConstraints.NONE; - c.weightx = c.weighty = 0.0; - c.gridx = 0; - c.gridy = 0; - c.anchor = GridBagConstraints.NORTHWEST; - - JLabel promptLabel = new JLabel( - pmUtility.getResource("Matching.entries:")); -/* - * MNEMONIC - * promptLabel.setDisplayedMnemonic( - * pmUtility.getIntResource("Matching.entries:.mnemonic")); - */ - - this.add(promptLabel, c); - - c.gridy = 1; - c.anchor = GridBagConstraints.WEST; - - selectButton = new pmButton( - pmUtility.getResource("Show")); - selectButton.setMnemonic( - pmUtility.getIntResource("Show.mnemonic")); - - selectButton.setEnabled(false); - - this.add(selectButton, c); - - selectButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - pmHelpItem selectedItem = (pmHelpItem) - resultList.getSelectedValue(); - Debug.message("Selected " + selectedItem); - parentPanel.controller.showHelpItem(selectedItem); - } - }); - - Vector resultItems = null; - try { - // resultItems = pmHelpIndexQueryPanel.helpDB.getPartialMatch(""); - resultItems = pmHelpRepository.helpItemsForString(""); - } catch (pmHelpException x) { - Debug.message("pmHelpIndexResultpanel init: " + x); - resultItems = new Vector(); - resultItems.addElement( - pmUtility.getResource("Nothing.matched.")); - } - - resultList = new JList(resultItems); - JScrollPane scrollPane = new JScrollPane(); - scrollPane.getViewport().setView(resultList); - resultList.setVisibleRowCount(8); - - promptLabel.setLabelFor(resultList); - - resultList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (!listEmpty) { - selectButton.setEnabled(true); - /* - * parentPanel.controller.frame. - * getRootPane().setDefaultButton(selectButton); - */ - selectButton.setAsDefaultButton(); - - } - }}); - - resultList.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - JList l = (JList) e.getSource(); - int i = l.locationToIndex(e.getPoint()); - Debug.message("doubleclick index: " + i); - if (!listEmpty && i >= 0) { - pmHelpItem item = - (pmHelpItem) l.getModel().getElementAt(i); - Debug.message("doubleclick: " + item.tag); - parentPanel.controller.showHelpItem(item); - } - } - } - }); - - c.gridwidth = 1; // 2; - c.gridx = 1; - c.gridy = 0; - c.weightx = c.weighty = 1.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.EAST; - - this.add(scrollPane, c); - - } - - void setResultList(Vector v) { - - resultList.setListData(v); - - resultList.setSelectedValue(v.elementAt(0), true); - } - - void setListEmpty(boolean e) { - listEmpty = e; - selectButton.setEnabled(false); - /* - * parentPanel.controller.frame.getRootPane(). - * setDefaultButton(parentPanel.controller.frame.dismiss); - */ - if (parentPanel.controller.frame.dismiss != null) - parentPanel.controller.frame.dismiss. - setAsDefaultButton(); - } - -} - - -class pmHelpIndexQueryPanel extends JPanel { - - JTextField query; - pmHelpIndexPanel parentPanel; - - public pmHelpIndexQueryPanel(pmHelpIndexPanel p) { - - parentPanel = p; - - this.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(10, 10, 10, 10); - c.fill = GridBagConstraints.NONE; - c.weightx = c.weighty = 0.0; - c.anchor = GridBagConstraints.WEST; - - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 10, 10); - - JLabel promptLabel = - new JLabel(pmUtility.getResource("Search.help.index.for:")); -/* - * MNEMONIC - * promptLabel.setDisplayedMnemonic( - * pmUtility.getIntResource("Search.help.index.for:.mnemonic")); - */ - - this.add(promptLabel, c); - - query = new JTextField(); - query.setEditable(true); - query.setText(""); - - promptLabel.setLabelFor(query); - - query.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.info("HELP: Action!"); - parentPanel.resultPanel.selectButton.doClick(); - } - }); - - c.gridwidth = GridBagConstraints.REMAINDER; - c.gridx = 1; - c.weightx = 1.0; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.EAST; - - this.add(query, c); - - DocumentListener d = new DocumentListener() { - public void changedUpdate(DocumentEvent e) { - // ignore - } - - public void insertUpdate(DocumentEvent e) { - handleText(query.getText()); - } - - public void removeUpdate(DocumentEvent e) { - handleText(query.getText()); - } - }; - - query.getDocument().addDocumentListener(d); - } - - public void handleText(String txt) { - - Debug.message("Got text " + txt); - - Vector v = null; - - try { - // v = helpDB.getPartialMatch(txt); - v = pmHelpRepository.helpItemsForString(txt); - } catch (pmHelpException x) { - Debug.warning("handleText: " + x); - } - parentPanel.setSearchResults(v); - - } - - // belongs in controller? - // static pmHelpRepository helpDB = new pmHelpRepository(); -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpItem.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpItem.java deleted file mode 100644 index 94dab47210..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpItem.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpItem - * Abstraction of a help article - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; - -import com.sun.admin.pm.server.*; - -class pmHelpItem extends Object { - String title; - String tag; - Vector keywords; - Vector seealso; - pmHelpContent content; - - public pmHelpItem(String theTag) { - tag = theTag; - title = null; - keywords = null; - seealso = null; - content = null; - } - - public String toString() { - /* - * String s = new String("Item: " + tag + "\n"); - * s += ("\ttitle: " + title + "\n"); - * s += ("\tkeywords: " + keywords + "\n"); - * s += ("\tseealso: " + seealso + "\n"); - * s += ("\tcontent: " + content + "\n"); - */ - return title; - } - - - public void setTag(String s) { - if (tag != null) - tag = new String(s); - } - - public void setTitle(String s) { - if (s != null) - title = new String(s); - } - - public void setKeywords(Vector v) { - if (v != null) - keywords = (Vector) v.clone(); - } - - public void setSeeAlso(Vector v) { - if (v != null) - seealso = (Vector) v.clone(); - } - - public void setContent(pmHelpContent c) { - if (c != null) - content = new pmHelpContent(c); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpRepository.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpRepository.java deleted file mode 100644 index 45698ff0d5..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpRepository.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 1999-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmHelpRepository.java - * Database of help articles - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; - -import com.sun.admin.pm.server.*; - - - -/* - * The help repository manages three distinct databases. - * - * helpItemDB: String tag -> pmHelpItem - * Returns a pmHelpItem given its unique tag. - * Used to resolve a reference from the app. - * - * helpKeywordDB: String -> Vector(of pmHelpItems) - * Returns a Vector containing all pmHelpItems whose `keywords' - * property contains the specifed keyword. - * - * helpTitleDB: String -> Vector (of pmHelpItems) - * Returns a Vector containing all pmHelpItems whose `title' - * property is a partial match for the specified string. - */ - -final class pmHelpRepository { - - private static Hashtable helpItemDB = null; - private static Hashtable helpKeywordDB = null; - private static BST helpTitleDB = null; - - - // database of HelpItems, by tag string - static void populateHelpItemDB() { - helpItemDB = new Hashtable(); - loadHelpItemDB(); - // Debug.message("HELP: helpItemDB: " + helpItemDB); - } - - // database of Vectors of HelpItems, by keyword string - static void populateHelpKeywordDB() { - if (helpItemDB == null) - return; - - /* - * Strategy: - * for each item - * for each keyword - * if kw not in db - * add ititem.tag - * add item to keyword entry - */ - - helpKeywordDB = new Hashtable(); - - Vector v = null; - Enumeration items = helpItemDB.elements(); - while (items.hasMoreElements()) { - pmHelpItem item = (pmHelpItem) items.nextElement(); - Enumeration keywords = item.keywords.elements(); - while (keywords.hasMoreElements()) { - String keyword = (String) keywords.nextElement(); - v = (Vector) helpKeywordDB.get(keyword); - if (v == null) - helpKeywordDB.put(keyword, v = new Vector()); - v.addElement(item); - } - } - - // Debug.message("HELP: KeywordDB: " + helpKeywordDB); - } - - - // database of HelpItems, by (partial) title string - static void populateHelpTitleDB() { - if (helpItemDB == null) - return; - - /* - * strategy: - * assume itemDB is loaded - * for each item in itemDB - * create an entry in titleDB - */ - - helpTitleDB = new BST(); - - Enumeration items = helpItemDB.elements(); - while (items.hasMoreElements()) { - pmHelpItem item = (pmHelpItem) items.nextElement(); - helpTitleDB.insert(item.title, item); - } - } - - - static public pmHelpItem helpItemForTag(String tag) { - if (helpItemDB == null || tag == null) - return null; - return (pmHelpItem) helpItemDB.get(tag); - } - - static public Vector helpItemsForKeyword(String keyword) { - if (helpKeywordDB == null) - return null; - - return (Vector) helpKeywordDB.get(keyword.toLowerCase()); - } - - - static public Vector helpItemsForString(String partialTitle) - throws pmHelpException { - - Debug.info("HELP: helpItemsForString: " + partialTitle); - - if (helpTitleDB == null) - return new Vector(); - - Vector v = new Vector(); - helpTitleDB.traverse_find_vector(v, partialTitle); - - Debug.info("HELP: helpItemsForString: vector contains " + - v.size() + " items"); - - return v; - } - - - - - // this should go in utils... - public static String getResource(String key) { - String keyvalue = null; - ResourceBundle bundle = null; - - Debug.message("HELP: getResource(" + key + ")"); - - try { - try { - bundle = ResourceBundle.getBundle( - "com.sun.admin.pm.client.pmHelpResources"); - } catch (MissingResourceException e) { - Debug.fatal("HELP: Could not load pmHelpResources file"); - } - - try { - keyvalue = bundle.getString(key); - } catch (MissingResourceException e) { - keyvalue = bundle.getString("Missing:") + key; - Debug.error("HELP: Missing: " + key); - } - } catch (Exception other) { - Debug.error("HELP: getResource(" + key + ") : " + other); - } - - return keyvalue; - } - - - // from resources, presumably - static public void loadHelpItemDB() { - - // Debug.setDebugLevel(new pmHelpRepository(), Debug.ALL); - - /* - * strategy: - * for each tag name (from pmHelpTagNameEnumerator): - * get the property values from the resource bundle - */ - - Debug.message("HELP: Starting help item load"); - - ResourceBundle bundle = null; - - try { - bundle = ResourceBundle.getBundle( - "com.sun.admin.pm.client.pmHelpResources"); - } catch (MissingResourceException e) { - Debug.fatal("HELP: Could not load pmHelpResources file"); - return; - } - Enumeration e = bundle.getKeys(); - while (e.hasMoreElements()) { - String key = (String) e.nextElement(); - if (key.endsWith(".tag")) { - String tagName = null; - try { - tagName = bundle.getString(key); - } catch (MissingResourceException x) { - Debug.warning("HELP: Unable to find tag for " + key); - continue; - } - - Debug.message("HELP: Making new item " + tagName); - - pmHelpItem item = new pmHelpItem(tagName); - - String theTitle = getResource(tagName + ".title"); - item.setTitle(theTitle); - - item.setContent(new pmHelpContent( - getResource(tagName + ".content"))); - - Vector v = null; - StringTokenizer st = null; - - String s = getResource(tagName + ".seealso"); - if (s != null) { - v = new Vector(); - st = new StringTokenizer(s); - while (st.hasMoreTokens()) - v.addElement(st.nextToken()); - item.setSeeAlso(v); - } - - v = new Vector(); - s = getResource(tagName + ".keywords"); - if (s != null) { - st = new StringTokenizer(s); - while (st.hasMoreTokens()) { - String word = st.nextToken(); - String quotelessWord = word.replace('\"', ' '); - v.addElement(quotelessWord.trim()); - } - } else - Debug.warning("HELP: Item " + tagName + - " keywords is empty"); - - - // insert item's title words into its keywords - st = new StringTokenizer(theTitle); - while (st.hasMoreTokens()) { - String word = (st.nextToken()).toLowerCase(); - - // ignore useless words - if (ignoreKeyTitleWords.indexOf(word) != -1) { - Debug.message("HELP: ignoring " + word + - " from " + theTitle); - continue; - } - - Debug.message("HELP: adding " + word + - " from " + theTitle); - - v.addElement(word); - } - - item.setKeywords(v); - - - Debug.message("HELP: New item: " + item); - - helpItemDB.put(item.tag, item); - } - } - } - - - // these words are not to be treated as keywords when they appear in title - static final private String - /* JSTYLED */ - ignoreKeyTitleWords = pmUtility.getResource("help.ignore.words"); -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpSearchPanel.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpSearchPanel.java deleted file mode 100644 index 03c0aefeba..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmHelpSearchPanel.java +++ /dev/null @@ -1,451 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHelpSearchPanel.java - * Search help keywords - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.JPanel; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -public class pmHelpSearchPanel extends JPanel { - - pmHelpController controller; - pmHelpSearchQueryPanel queryPanel; - pmHelpSearchResultPanel resultPanel; - JLabel textPanels[]; - - public pmHelpSearchPanel(pmHelpController ctrl) { - controller = ctrl; - - // build subpanels - queryPanel = new pmHelpSearchQueryPanel(this); - resultPanel = new pmHelpSearchResultPanel(this); - - textPanels = new JLabel[4]; - textPanels[0] = new JLabel( - pmUtility.getResource("To.find.help.articles...")); - textPanels[1] = new JLabel( - pmUtility.getResource("enter.keywords.below...")); - - // lay out top panel - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(5, 5, 5, 5); - c.gridwidth = GridBagConstraints.REMAINDER; - c.gridx = 0; - c.gridy = 0; - c.gridheight = 1; // GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1.0; - c.weighty = 0.0; - - JPanel p = new JPanel(); - p.setLayout(new GridBagLayout()); - GridBagConstraints pc = new GridBagConstraints(); - pc.insets = new Insets(5, 5, 0, 5); - // pc.fill = GridBagConstraints.HORIZONTAL; - pc.weightx = 1.0; - pc.anchor = GridBagConstraints.WEST; - pc.gridx = 0; - pc.gridy = GridBagConstraints.RELATIVE; - - p.add(textPanels[0], pc); - pc.insets = new Insets(0, 5, 5, 5); - p.add(textPanels[1], pc); - // p.add(textPanels[2]); - - this.add(p, c); - - - p = new JPanel(); - p.setLayout(new BorderLayout()); - queryPanel.setBorder(BorderFactory.createEtchedBorder()); - p.add(queryPanel, "North"); - resultPanel.setBorder(BorderFactory.createEtchedBorder()); - p.add(resultPanel, "Center"); - // p.setBorder(BorderFactory.createEtchedBorder()); - - c.gridy = 1; - // new stuff - c.gridy = GridBagConstraints.RELATIVE; - c.gridheight = 0; - c.weighty = 1.0; - c.weightx = 0.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.EAST; - // end new stuff - - this.add(p, c); - this.setBorder(BorderFactory.createEtchedBorder()); - - - // figure out when we are tabbed or un-tabbed - controller.outerPanel.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - JTabbedPane tp = (JTabbedPane) e.getSource(); - Debug.info("HELP: Tab event!"); - if (!(tp.getSelectedComponent() instanceof - com.sun.admin.pm.client.pmHelpSearchPanel)) { - Debug.info("HELP: Tab event: resetting default"); - /* - * controller.frame.getRootPane(). - * setDefaultButton( - * controller.frame.dismiss); - */ - /* - * System.out.println(controller); - * System.out.println(controller.frame); - * System.out.println(controller.frame.dismiss); - */ - - if (controller.frame.dismiss != null) - controller.frame.dismiss. - setAsDefaultButton(); - } else { - // better to have the tab itself keep focus. - // queryPanel.query.requestFocus(); - } - } - }); - - } - - - // place item titles in search result panel - public void setSearchResults(Vector items) { - Vector v = new Vector(); - - if (items.size() == 0) { - resultPanel.setListEmpty(true); - v.addElement(pmUtility.getResource("Nothing.matched.")); - } else { - Enumeration e = items.elements(); - while (e.hasMoreElements()) { - pmHelpItem i = (pmHelpItem) e.nextElement(); - v.addElement(i); - } - resultPanel.setListEmpty(false); - } - resultPanel.setResultList(v); - } -} - - - -class pmHelpSearchResultPanel extends JPanel { - - JList resultList = null; - pmButton selectButton = null; - pmHelpSearchPanel parentPanel = null; - protected boolean listEmpty = true; - - - public pmHelpSearchResultPanel(pmHelpSearchPanel par) { - - parentPanel = par; - - this.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(10, 10, 10, 10); - c.fill = GridBagConstraints.NONE; - c.weightx = c.weighty = 0.0; - c.gridx = 0; - c.gridy = 0; - c.anchor = GridBagConstraints.NORTHWEST; - - JLabel promptLabel = new JLabel( - pmUtility.getResource("Search.Results:")); -/* - * MNEMONIC - * promptLabel.setDisplayedMnemonic( - * pmUtility.getIntResource("Search.Results:.mnemonic")); - */ - - this.add(promptLabel, c); - - selectButton = new pmButton( - pmUtility.getResource("Show")); - selectButton.setMnemonic( - pmUtility.getIntResource("Show.mnemonic")); - - selectButton.setEnabled(false); - - selectButton.addActionListener(new ActionListener() { - // load the selected item into view panel - public void actionPerformed(ActionEvent e) { - pmHelpItem selectedItem = (pmHelpItem) - resultList.getSelectedValue(); - Debug.info("HELP: Selected " + selectedItem); - parentPanel.controller.showHelpItem(selectedItem); - - } - }); - - c.gridy = 1; - c.anchor = GridBagConstraints.SOUTHWEST; - this.add(selectButton, c); - - - Vector resultItems = new Vector(); - - resultList = new JList(resultItems); - JScrollPane scrollPane = new JScrollPane(); - scrollPane.getViewport().setView(resultList); - resultList.setVisibleRowCount(8); - - promptLabel.setLabelFor(resultList); - - resultList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (!listEmpty) { - selectButton.setEnabled(true); - /* - * parentPanel.controller.frame. - * getRootPane().setDefaultButton(selectButton); - */ - selectButton.setAsDefaultButton(); - - } - }}); - - - resultList.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - JList l = (JList) e.getSource(); - int i = l.locationToIndex(e.getPoint()); - Debug.info("HELP: doubleclick index: " + i); - if (!listEmpty && i >= 0) { - pmHelpItem item = (pmHelpItem) l.getModel(). - getElementAt(i); - Debug.info("HELP: doubleclick: " + item.tag); - parentPanel.controller.showHelpItem(item); - } - } - } - }); - - - c.gridwidth = 2; - c.gridx = 1; - c.gridy = 0; - c.weightx = c.weighty = 1.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.WEST; - - this.add(scrollPane, c); - - } - - public void setResultList(Vector v) { - resultList.setListData(v); - resultList.setSelectedValue(v.elementAt(0), true); - - } - - void setListEmpty(boolean e) { - listEmpty = e; - selectButton.setEnabled(false); - /* - * parentPanel.controller.frame.getRootPane(). - * setDefaultButton(parentPanel.controller.frame.dismiss); - */ - parentPanel.controller.frame.dismiss.setAsDefaultButton(); - - } - - -} - - -class pmHelpSearchQueryPanel extends JPanel { - - JTextField query; - pmButton search; - pmHelpSearchPanel parentPanel = null; - - public pmHelpSearchQueryPanel(pmHelpSearchPanel par) { - - parentPanel = par; - - this.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(10, 10, 10, 10); - c.fill = GridBagConstraints.NONE; - c.weightx = c.weighty = 0.0; - c.anchor = GridBagConstraints.WEST; - - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 1; - c.gridheight = 1; - - JLabel promptLabel = - new JLabel(pmUtility.getResource("Keywords:")); -/* - * MNEMONIC - * promptLabel.setDisplayedMnemonic( - * pmUtility.getIntResource("Keywords:.mnemonic")); - */ - - this.add(promptLabel, c); - - search = new pmButton( - pmUtility.getResource("Find")); - search.setMnemonic( - pmUtility.getIntResource("Find.mnemonic")); - - search.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - // parse the keyword strings - Vector v = null; - StringTokenizer st = null; - String s = query.getText(); - if (s != null) { - v = new Vector(); - st = new StringTokenizer(s); - while (st.hasMoreTokens()) - v.addElement(st.nextToken()); - v = getItemsForKeywords(v); - parentPanel.setSearchResults(v); - - if (v != null && v.size() != 0) { - Debug.info("HELP: search vector full"); - parentPanel.resultPanel.resultList.requestFocus(); - } else { - Debug.info("HELP: search vector empty"); - } - } - - } - }); - - c.fill = GridBagConstraints.NONE; - c.gridx = 2; - c.gridy = 0; // GridBagConstraints.RELATIVE; - this.add(search, c); - - query = new JTextField(); - query.setEditable(true); - query.setText(" "); - - promptLabel.setLabelFor(query); - - query.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.info("HELP: Action!"); - pmHelpSearchQueryPanel.this.search.doClick(); - } - }); - - query.getDocument().addDocumentListener(new DocumentListener() { - public void changedUpdate(DocumentEvent e) { - // ignore - } - - public void insertUpdate(DocumentEvent e) { - // make search the default button - Debug.info("HELP: search doc inserted update"); - pmHelpSearchQueryPanel.this.search.setEnabled(true); - /* - * parentPanel.controller.frame. - * getRootPane().setDefaultButton( - * pmHelpSearchQueryPanel.this.search); - */ - if (pmHelpSearchQueryPanel.this.search != null) - pmHelpSearchQueryPanel.this.search. - setAsDefaultButton(); - } - - public void removeUpdate(DocumentEvent e) { - Debug.info("HELP: search doc removed update"); - // restore the default button - if (query.getText().length() == 0) { - /* - * parentPanel.controller.frame. - * getRootPane().setDefaultButton( - * parentPanel.controller.frame.dismiss); - */ - if (parentPanel.controller.frame.dismiss != null) - parentPanel.controller.frame.dismiss. - setAsDefaultButton(); - } - } - }); - - - - c.gridwidth = 1; // GridBagConstraints.REMAINDER; - c.gridx = 1; - c.weightx = 1.0; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.EAST; - - this.add(query, c); - - } - - - Vector getItemsForKeywords(Vector keywords) { - Vector result = new Vector(); - - Debug.info("HELP: getItemsForKeywords: " + keywords); - - Enumeration words = keywords.elements(); - while (words.hasMoreElements()) { - String s = (String) words.nextElement(); - Vector newItems = pmHelpRepository.helpItemsForKeyword(s); - Debug.info("HELP: getItemsForKeywords new items: " + newItems); - - if (newItems != null) { - Enumeration items = newItems.elements(); - while (items.hasMoreElements()) { - pmHelpItem i = (pmHelpItem) items.nextElement(); - Debug.info("HELP: getItemsForKeywords result: " + result); - Debug.info("HELP: getItemsForKeywords item: " + i); - - if (!result.contains(i)) - result.addElement(i); - } - } - } - return result; - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmIncompleteFormException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmIncompleteFormException.java deleted file mode 100644 index 48926b44e8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmIncompleteFormException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmIncompleteFormException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmIncompleteFormException extends pmGuiException { - public pmIncompleteFormException(String s) { - super(s); - } - public pmIncompleteFormException() { - super(); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmInstallPrinter.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmInstallPrinter.java deleted file mode 100644 index e24f1425d1..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmInstallPrinter.java +++ /dev/null @@ -1,2194 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Install and Modify Printer implementation - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.Vector; -import javax.swing.JPanel; -import javax.swing.*; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.table.AbstractTableModel; - -import com.sun.admin.pm.server.*; - - -/* - * Window for Edit -> Install Printer - */ - -public class pmInstallPrinter extends pmInstallScreen { - - int action; - pmTop myTop; - pmFrame frame; - JScrollPane scrollPane; - String printer = null; - String server = null; - String description = null; - String port = null; - String ptype = null; - String fcontents = null; - String make = null; - String model = null; - String ppd = null; - String ppdfile = null; - String oldmake = new String("oldmake"); - String oldmodel = new String("oldmodel"); - String faultn = null; - String banner = null; - String destination = null; - String protocol = null; - String useraccesslist[] = null; - String oldptype = null; - String olddevice = null; - Printer workingPrinter; - - JList accessList; - JScrollPane ascrollPane; - accessListModel accessModel; - - String helpTag = null; - - String cmdLog = null; - String errorLog = null; - String warnLog = null; - - String actionName = null; - - // where to place initial focus - Component defaultComponent = null; - - boolean usePPD; - boolean useLocalhost; - - public pmInstallPrinter(pmTop myTop, int action) throws pmGuiException { - boolean failed = false; - boolean cacheerr = false; - boolean ppdincacheerr = false; - - this.myTop = myTop; - this.action = action; - workingPrinter = new Printer(myTop.ns); - - usePPD = myTop.getUsePPD(); - useLocalhost = myTop.getUseLocalhost(); - - switch (action) { - - case Constants.ADDLOCAL: - - Debug.message("CLNT:pmInstPr: ADD LOCAL"); - frame = new pmFrame( - pmUtility.getResource("SPM:New.Attached.Printer")); - if (pmMisc.isppdCachefile() && usePPD) { - helpTag = "InstallLocalPPD"; - } else { - helpTag = "InstallLocal"; - } - actionName = - pmUtility.getResource("New.Attached.Printer"); - break; - - case Constants.ADDNETWORK: - - Debug.message("CLNT:pmInstPr: ADD NETWORK"); - frame = new pmFrame( - pmUtility.getResource("SPM:New.Network.Printer")); - if ((pmMisc.isppdCachefile()) && (usePPD)) { - helpTag = "InstallNetworkPPD"; - } else - helpTag = "InstallNetwork"; - actionName = pmUtility.getResource("New.Network.Printer"); - break; - - case Constants.MODIFYATTACHED: - - Debug.message("CLNT:pmInstPr: MODIFY ATTACHED"); - frame = new pmFrame( - pmUtility.getResource("SPM:Modify.Printer.Properties")); - workingPrinter.setPrinterName(myTop.selectedPrinter); - - failed = false; - try { - workingPrinter.getPrinterDetails(); - - } catch (pmNeedPPDCacheException e) { - cacheerr = true; - Debug.message("CLNT:pmInstPr:ModifyAttached caught: " + e); - - } catch (pmCacheMissingPPDException e) { - ppdincacheerr = true; - Debug.message("CLNT:pmInstPr:ModifyAttached caught: " + e); - - } catch (Exception e) { - failed = true; - Debug.message("CLNT:pmInsPr:ModifyAttached caught:" + e); - } - - gatherLogs(workingPrinter); - - if (cacheerr) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Cannot.modify.this.queue;ppdcache.file.missing.")); - - m.setVisible(true); - - throw new pmGuiException("No ppdcache file"); - } - - if (ppdincacheerr) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Cannot.modify.this.queue;PPD.file.not.in.ppdcache.")); - - m.setVisible(true); - - throw new pmGuiException("PPD file not in ppdcache"); - } - - if (failed) { - // error popup? - // throw something? - } - - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("ModifyAttached()"); - - if (workingPrinter.getPPD() != null) - helpTag = "ModifyPPD"; - else - helpTag = "Modify"; - - // helpTag = "ModifyAttached"; - - actionName = pmUtility.getResource("Modify.Printer.Properties"); - break; - - case Constants.MODIFYNETWORK: - - Debug.message("CLNT:pmInstPr: MODIFY NETWORK"); - frame = new pmFrame( - pmUtility.getResource("SPM:Modify.Printer.Properties")); - workingPrinter.setPrinterName(myTop.selectedPrinter); - - workingPrinter.setPrinterName(myTop.selectedPrinter); - failed = false; - - try { - workingPrinter.getPrinterDetails(); - } catch (Exception e) { - failed = true; - Debug.message("CLNT:pmInstPr:ModifyNetwork caught " + e); - } - - gatherLogs(workingPrinter); - - if (failed) { - // error popup? - // throw new pmGuiException(); - } - - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("ModifyNetwork()"); - - if (workingPrinter.getPPD() != null) - helpTag = "ModifyPPD"; - else - helpTag = "Modify"; - // helpTag = "ModifyNetwork"; - - actionName = pmUtility.getResource("Modify.Printer.Properties"); - - break; - - case Constants.MODIFYREMOTE: - Debug.message("CLNT:pmInstPr: MODIFY REMOTE"); - frame = new pmFrame( - pmUtility.getResource("SPM:Modify.Printer.Properties")); - - workingPrinter.setPrinterName(myTop.selectedPrinter); - - failed = false; - try { - workingPrinter.getPrinterDetails(); - } catch (Exception e) { - failed = true; - Debug.warning("CLNT:pmInstPr:ModifyRemote caught " + e); - } - gatherLogs(workingPrinter); - - if (failed) { - // error popup? - // throw something? - } - - - if (workingPrinter.getPPD() != null) - helpTag = "ModifyPPD"; - else - helpTag = "Modify"; - // helpTag = "ModifyRemote"; - - actionName = pmUtility.getResource("Modify.Printer.Properties"); - break; - - } - - // ensure that pmButton hashtable gets cleaned up - frame.setClearButtonsOnClose(true); - - setLayout(new BorderLayout()); - - // Build the Screen - northPanel(); - if (action != Constants.MODIFYREMOTE) { - centerPanel(); - } - - southPanel(); - - // default button is always OK, for now... - // frame.getRootPane().setDefaultButton (okButton); - // okButton.setAsDefaultButton (); - - // handle Esc as cancel - this.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - actioncancelButton(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - if (action == Constants.ADDLOCAL || action == Constants.ADDNETWORK) { - defaultComponent = pnameText; - } else { - defaultComponent = descText; - } - - frame.setDefaultComponent(defaultComponent); - - defaultComponent.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - Debug.info("\ncomponent focus gained: " + e); - } - public void focusLost(FocusEvent e) { - Debug.info("\ncomponent focus lost: " + e); - } - }); - - } - - - public class accessListModel extends AbstractListModel { - int numColumns; - Vector data; - Vector access = new Vector(1, 1); - - public accessListModel() { - numColumns = getColumnCount(); - } - - public void addaccessList(String data[]) { - - for (int i = 0; i < data.length; i++) { - access.addElement(data[i]); - - } - } - - public void addaccessList(String data) { - access.addElement(data); - } - - public boolean isduplicate(String d) { - if (access == null) - return false; - else - return access.contains(d); - } - - public void removeRow(int row) { - access.removeElementAt(row); - } - - public void removeListEntries() { - access.removeAllElements(); - } - - public int getRowCount() { - return access.size(); - } - - public int getSize() { - return access.size(); - } - - public int getColumnCount() { - return 1; - } - - public void addRow(Vector row) { - access.addElement(row); - } - - public Object getValueAt(int row) { - return access.elementAt(row); - } - - public Object getElementAt(int row) { - return access.elementAt(row); - } - - public Object getValueAt(int row, int col) { - return access.elementAt(row); - } - - public void setValueAt(String value, int row) { - access.setElementAt(value, row); - } - - public Vector getAccessList() { - return access; - } - - public void accesstoArray(String[] target) { - access.copyInto(target); - } - - } - - public void centerPanel() { - JPanel center = new JPanel(); - - accessModel = new accessListModel(); - accessList = new JList(accessModel); - accessList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - - center.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - ListSelectionModel rowSelectModel = accessList.getSelectionModel(); - rowSelectModel.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - ListSelectionModel accessSM = - (ListSelectionModel)e.getSource(); - } - }); - - c.insets = new Insets(5, 5, 5, 5); - - // Create the label - c.gridx = 0; - c.gridy = 0; - labelConstraints(c); - center.add(new JLabel - (pmUtility.getResource("User.Access.List:")), c); - - // Create User Access List - String[] tmp = workingPrinter.getUserAllowList(); - - - if (tmp == null) { - accessModel.addaccessList("all"); - } else { - accessModel.addaccessList(tmp); - } - - ascrollPane = new JScrollPane(accessList); - - c.gridwidth = 2; - c.gridx = 1; - c.weightx = c.weighty = 1.0; - c.fill = GridBagConstraints.BOTH; - center.add(ascrollPane, c); - - // Create Textfield - c.gridx = 1; - c.gridy = 1; - c.ipadx = 15; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.WEST; - c.weightx = c.weighty = 1.0; - userText = new pmTextField(25); - center.add(userText, c); - - // Add the Add/Delete Buttons - c.gridx = 1; - c.gridy = 2; - - adButtons(c); - - c.gridwidth = 1; - center.add(addButton, c); - - c.gridx = 2; - center.add(deleteButton, c); - - add("Center", center); - - } - - public void northPanel() { - JPanel north = new JPanel(); - north.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - northPanelConstraints(c); - - // Define the constraints and create the labels - - // All Add/Modify - labelConstraints(c); - c.gridx = 0; - c.gridy = 0; - printernameLabel(north, c); - c.gridy++; - servernameLabel(north, c); - c.gridy++; - descriptionLabel(north, c); - c.gridy++; - - // Add printers, modify local - if (action != Constants.MODIFYREMOTE) { - - if ((action == Constants.ADDLOCAL) || - (action == Constants.MODIFYATTACHED)) { - printerportLabel(north, c); - c.gridy++; - } - - if ((action == Constants.ADDLOCAL) || - (action == Constants.ADDNETWORK)) { - if ((pmMisc.isppdCachefile()) && (usePPD)) { - printermakeLabel(north, c); - c.gridy++; - printermodelsLabel(north, c); - c.gridy++; - ppdcontentsLabel(north, c); - } else { - printertypeLabel(north, c); - c.gridy++; - filecontentsLabel(north, c); - } - } - - if ((action == Constants.MODIFYATTACHED) || - (action == Constants.MODIFYNETWORK)) { - - // Show make/model/ppd or type/contents - - if (workingPrinter.getPPD() != null) { - - printermakeLabel(north, c); - c.gridy++; - printermodelsLabel(north, c); - c.gridy++; - ppdcontentsLabel(north, c); - } else { - printertypeLabel(north, c); - c.gridy++; - filecontentsLabel(north, c); - } - } - - c.gridy++; - faultnotLabel(north, c); - c.gridy++; - - if (action == Constants.ADDNETWORK || - action == Constants.MODIFYNETWORK) { - destinationLabel(north, c); - c.gridy++; - protocolLabel(north, c); - c.gridy++; - } - - optionsLabel(north, c); - c.gridy++; - bannerLabel(north, c); - } else { - optionLabel(north, c); - } - - // Define the constraints and create the fields - - // Add printers - c.gridx = 1; - c.gridy = 0; - - // Printer Name and Server Name - if ((action == Constants.ADDLOCAL) || - (action == Constants.ADDNETWORK)) { - - TextFieldConstraints(c); - printernameTextField(north, c); - c.gridy++; - labelConstraints(c); - try { - north.add(new JLabel( - myTop.host.getLocalHostName()), c); - } catch (Exception e) { - Debug.warning( - "CLNT:pmInstPr:getLocalHostName exception " + e); - north.add(new JLabel(" "), c); - } - c.gridy++; - } else { - labelConstraints(c); - north.add(new JLabel(myTop.selectedPrinter), c); - c.gridy++; - labelConstraints(c); - north.add(new JLabel(myTop.selprinterServer), c); - c.gridy++; - } - - // Description - TextFieldConstraints(c); - descriptionField(north, c); - if (action == Constants.MODIFYATTACHED || - action == Constants.MODIFYNETWORK || - action == Constants.MODIFYREMOTE) { - if (workingPrinter.getComment() != null) - descText.setText(workingPrinter.getComment()); - } - c.gridy++; - - if (action != Constants.MODIFYREMOTE) { - if (action == Constants.ADDLOCAL) { - comboboxConstraints(c); - printerportField(north, c); - c.gridy++; - - } else if (action == Constants.MODIFYATTACHED) { - labelConstraints(c); - north.add(new JLabel(workingPrinter.getDevice()), c); - c.gridy++; - } - - comboboxConstraints(c); - - if ((action == Constants.ADDLOCAL) || - (action == Constants.ADDNETWORK)) { - if ((pmMisc.isppdCachefile()) && (usePPD)) { - printermakeField(north, c); - c.gridy++; - printermodelsField(north, c); - c.gridy++; - ppdcontentsField(north, c); - } else { - printertypeField(north, c); - c.gridy++; - filecontentsField(north, c); - } - } - - if ((action == Constants.MODIFYATTACHED) || - (action == Constants.MODIFYNETWORK)) { - - if (workingPrinter.getPPD() != null) { - - printermakeField(north, c); - c.gridy++; - printermodelsField(north, c); - c.gridy++; - ppdcontentsField(north, c); - - setMake(); - setModel(); - setPPD(); - - } else { - // display with printer type and file contents - - printertypeField(north, c); - setPrinterType(); - - c.gridy++; - - filecontentsField(north, c); - setType(); - } - } - - c.gridy++; - - faultnotField(north, c); - if (action == Constants.MODIFYATTACHED || - action == Constants.MODIFYNETWORK) { - - setFault(); - } - c.gridy++; - - if (action == Constants.ADDNETWORK || - action == Constants.MODIFYNETWORK) { - - TextFieldConstraints(c); - destinationField(north, c); - c.gridy++; - comboboxConstraints(c); - protocolField(north, c); - c.gridy++; - if (action == Constants.MODIFYNETWORK) - setNetworkInfo(); - } - - optionsConstraints(c); - optionsFields(north, c); - if (action == Constants.MODIFYATTACHED || - action == Constants.MODIFYNETWORK) { - if (workingPrinter.getIsDefaultPrinter()) { - defaultp.doClick(); - } - setBanner(); - } - } else { - optionsConstraints(c); - defaultoptionField(north, c); - if (workingPrinter.getIsDefaultPrinter()) { - defaultp.doClick(); - } - } - - add("North", north); - } - - public void setNetworkInfo() { - String p = workingPrinter.getProtocol(); - - if (p != null) { - if (p.equals("bsd")) - protocolCombo.setSelectedItem("BSD"); - else if (p.equals("tcp")) - protocolCombo.setSelectedItem("TCP"); - else if (p.equals("uri")) - protocolCombo.setSelectedItem("URI"); - - } - - if (destText != null) - destText.setText(workingPrinter.getDestination()); - } - - public void setMake() { - String make = workingPrinter.getMake(); - if (make != null) { - makeCombo.setSelectedItem(make); - } - } - public void setModel() { - String model = workingPrinter.getModel(); - if (model != null) - modelCombo.setSelectedItem(model); - } - public void setPPD() { - String ppd = workingPrinter.getPPD(); - if (ppd != null) - ppdCombo.setSelectedItem(ppd); - } - - public void setFault() { - String fault = workingPrinter.getNotify(); - - if (fault == null || fault == "none") - faultCombo.setSelectedItem( - pmUtility.getResource("None")); - - else if (fault.equals("write")) - faultCombo.setSelectedItem( - pmUtility.getResource("Write.to.Superuser")); - - else if (fault.equals("mail")) - faultCombo.setSelectedItem( - pmUtility.getResource("Mail.to.Superuser")); - else { - faultCombo.addItem(fault); - faultCombo.setSelectedItem(fault); - } - } - - public void setBanner() { - String banner = workingPrinter.getBanner(); - - if (banner == null) - bannerCombo.setSelectedItem( - pmUtility.getResource("Always.Print.Banner")); - - else if (banner.equals("never")) - bannerCombo.setSelectedItem( - pmUtility.getResource("Never.Print.Banner")); - - else if (banner.equals("always")) - bannerCombo.setSelectedItem( - pmUtility.getResource("Always.Print.Banner")); - - else if (banner.equals("optional")) - bannerCombo.setSelectedItem( - pmUtility.getResource("User.Selectable.Default.On")); - } - - public void setType() { - // lpadmin can combine things like: simple,any ... - - String filedata[] = workingPrinter.getFileContents(); - String filecontents = new String(); - - if (filedata == null) { - fileCombo.setSelectedItem( - pmUtility.getResource("None")); - } else { - for (int i = 0; i < filedata.length; i++) { - if (i > 0 && filedata[i] != null) - filecontents = filecontents.concat(","); - - filecontents = filecontents.concat(filedata[i]); - } - Debug.message("CLNT:pmInstPr:setType: filecontents = " + - filecontents); - - if (filecontents.equals("postscript")) { - fileCombo.setSelectedItem(pmUtility.getResource( - "PostScript")); - } else if (filecontents.equals("application/postscript")) { - fileCombo.setSelectedItem(pmUtility.getResource( - "PostScript")); - - } else if (filecontents.equals("simple")) { - fileCombo.setSelectedItem(pmUtility.getResource("ASCII")); - } else if (filecontents.equals("text/plain")) { - fileCombo.setSelectedItem(pmUtility.getResource("ASCII")); - - } else if (filecontents.equals("postscript,simple")) { - fileCombo.setSelectedItem(pmUtility.getResource( - "Both.PostScript.and.ASCII")); - } else if (filecontents.equals("simple,postscript")) { - fileCombo.setSelectedItem(pmUtility.getResource( - "Both.PostScript.and.ASCII")); - } else if (filecontents.equals( - "text/plain,application/postscript")) { - fileCombo.setSelectedItem(pmUtility.getResource( - "Both.PostScript.and.ASCII")); - - } else if (filecontents.equals("none")) { - fileCombo.setSelectedItem( - pmUtility.getResource("None")); - } else if (filecontents.equals("any")) { - fileCombo.setSelectedItem( - pmUtility.getResource("Any")); - } else if (filecontents.equals("application/octet-stream")) { - fileCombo.setSelectedItem( - pmUtility.getResource("Any")); - } else { - Debug.message( - "CLNT:pmInstPr:setType()unknown file contents type"); - fileCombo.addItem(filecontents); - fileCombo.setSelectedItem(filecontents); - } - } - } - - public void setPrinterType() { - int x = 0; - String type = workingPrinter.getPrinterType(); - Debug.message( - "CLNT:pmInstPrsetPrinterType(): printer type is " + type); - - if (type == null) - return; - - if (type.equals("PS")) { - typeCombo.setSelectedItem("PostScript"); - } else if (type.equals("hplaser")) { - typeCombo.setSelectedItem("HP Printer"); - } else if (type.equals("PSR")) { - typeCombo.setSelectedItem("Reverse PostScript"); - } else if (type.equals("epson2500")) { - typeCombo.setSelectedItem("Epson 2500"); - } else if (type.equals("ibmproprinter")) { - typeCombo.setSelectedItem("IBM ProPrinter"); - } else if (type.equals("qume5")) { - typeCombo.setSelectedItem("Qume Sprint 5"); - } else if (type.equals("daisy")) { - typeCombo.setSelectedItem("Daisy"); - } else if (type.equals("diablo")) { - typeCombo.setSelectedItem("Diablo"); - } else if (type.equals("datagraphix")) { - typeCombo.setSelectedItem("Datagraphix"); - } else if (type.equals("la100")) { - typeCombo.setSelectedItem("DEC LA100"); - } else if (type.equals("ln03")) { - typeCombo.setSelectedItem("DEC LN03"); - } else if (type.equals("decwriter")) { - typeCombo.setSelectedItem("Dec Writer"); - } else if (type.equals("ti800")) { - typeCombo.setSelectedItem("Texas Instruments 800"); - } else { - typeCombo.addItem(type); - typeCombo.setSelectedItem(type); - Debug.message( - "CLNT:pmInstPr:setPrinterType(): user defined type " + - type); - } - - } - - public void getMakeModelPPD() throws pmGuiException { - if (pmMisc.isppdCachefile()) { - getMake(); - - model = (String)modelCombo.getSelectedItem(); - ppd = (String)ppdCombo.getSelectedItem(); - } - } - - public void getTypeContents() throws pmGuiException { - ptype = (String)typeCombo.getSelectedItem(); - fcontents = (String)fileCombo.getSelectedItem(); - } - - public void getFault() throws pmGuiException { - faultn = (String)faultCombo.getSelectedItem(); - } - - public void getBanner() throws pmGuiException { - banner = (String)bannerCombo.getSelectedItem(); - } - - public void getPrinterServer() throws pmGuiException { - - // Printer Name is a required field. - printer = pnameText.getText(); - if (printer.equals("")) { - pnameText.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("Printer.name.required.")); - } - - if (!Valid.localPrinterName(printer)) { - pnameText.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("Printer.name.invalid.")); - } - - server = null; - try { - if ((useLocalhost)) - server = "localhost"; - else - server = myTop.host.getLocalHostName(); - } catch (Exception e) { - Debug.warning( - "CLNT:pmInstPr:getLocalHostName exception " + e); - } - - Debug.message( - "CLNT:pmInstPr:getPrinterServer(): printer is: " + printer); - Debug.message( - "CLNT:pmInstPr:getPrinterServer(): server is: " + server); - - } - - public void getPort() throws pmGuiException { - port = (String)portCombo.getSelectedItem(); - if (port.equals(pmUtility.getResource("Not.Selected"))) { - portCombo.requestFocus(); - throw new pmIncompleteFormException - (pmUtility.getResource( - "Printer.Port.Selection.required")); - } - Debug.message("CLNT:pmInstPr:getPort(): port is: " + port); - } - - public void getMake() throws pmGuiException { - make = (String)makeCombo.getSelectedItem(); - if (make.equals(pmUtility.getResource("Not.Selected"))) { - makeCombo.requestFocus(); - throw new pmIncompleteFormException - (pmUtility.getResource( - "Printer.Make.Selection.required")); - } - Debug.message("CLNT:pmInstPr:getMake(): make is: " + make); - } - - public void getNetworkInfo() throws pmIncompleteFormException { - destination = destText.getText(); - if (destination.equals("")) { - destText.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("Destination.required.")); - } - - if (!Valid.destination(destination)) { - destText.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("Destination.invalid.")); - } - - protocol = (String)protocolCombo.getSelectedItem(); - port = new String("/dev/null"); - Debug.message( - "CLNT:pmInstPr:getNetworkInfo(): destination is: " + - destination); - Debug.message( - "CLNT:pmInstPr:getNetworkInfo(): protocol is: " + protocol); - } - - public void getDescription() { - - String messy; - - messy = descText.getText(); - description = messy.trim(); - Debug.message( - "CLNT:pmInstPr:getDescription():description: " + "<" + - description + ">"); - - if (workingPrinter.getComment() == null && description.equals("")) - description = null; - - } - - public void getUserAccess() { - - if (accessModel.getRowCount() != 0) { - useraccesslist = new String[accessModel.getRowCount()]; - accessModel.accesstoArray(useraccesslist); - } else { - useraccesslist = null; - } - } - - public String gui2lpptype(String t) { - String lp; - - if (t != null) { - if (t.equals("PostScript")) - lp = new String("PS"); - else if (t.equals("HP Printer")) - lp = new String("hplaser"); - else if (t.equals("Reverse PostScript")) - lp = new String("PSR"); - else if (t.equals("Epson 2500")) - lp = new String("epson2500"); - else if (t.equals("IBM ProPrinter")) - lp = new String("ibmproprinter"); - else if (t.equals("Qume Sprint 5")) - lp = new String("qume5"); - else if (t.equals("Daisy")) - lp = new String("daisy"); - else if (t.equals("Diablo")) - lp = new String("diablo"); - else if (t.equals("Datagraphix")) - lp = new String("datagraphix"); - else if (t.equals("DEC LA100")) - lp = new String("la100"); - else if (t.equals("DEC LN03")) - lp = new String("ln03"); - else if (t.equals("Dec Writer")) - lp = new String("decwriter"); - else if (t.equals("Texas Instruments 800")) - lp = new String("ti800"); - else { - Debug.message( - "CLNT:pmIns:gui2lptype: printer type unknown: " + t); - lp = new String(t); - } - } else { - Debug.message("CLNT:pmInstPr:gui2lptype: input printer type null"); - lp = new String(""); - } - - return lp; - } - - public String[] gui2lpfcontents(String f) { - - String[] lp = null; - - if (f != null) { - if (f.equals(pmUtility.getResource("PostScript"))) { - lp = new String[1]; - lp[0] = new String("postscript"); - } else if (f.equals(pmUtility.getResource("ASCII"))) { - lp = new String[1]; - lp[0] = new String("simple"); - } else if (f.equals(pmUtility.getResource( - "Both.PostScript.and.ASCII"))) { - lp = new String[2]; - lp[0] = new String("simple"); - lp[1] = new String("postscript"); - } else if (f.equals(pmUtility.getResource("Any"))) { - lp = new String[1]; - lp[0] = new String("any"); - } else if (f.equals(pmUtility.getResource("None"))) { - lp = new String[1]; - lp[0] = new String("none"); - } - } else { - Debug.message( - "CLNT:pmInstPr:gui2lpfcontents(): input string null"); - } - - return lp; - } - - public String gui2lpfaultn(String n) { - String lp = null; - if (n != null) { - if (n.equals(pmUtility.getResource("Write.to.Superuser"))) - lp = new String("write"); - else if (n.equals(pmUtility.getResource("Mail.to.Superuser"))) - lp = new String("mail"); - else if (n.equals(pmUtility.getResource("None"))) - lp = new String("none"); - - } else { - Debug.message( - "CLNT:pmInstPr:gui2lpfaultn():input faultnotify null"); - } - return lp; - } - - public String gui2lpprotocol(String p) { - String lp = null; - if (p.equals("TCP")) - lp = new String("tcp"); - else if (p.equals("BSD")) - lp = new String("bsd"); - else if (p.equals("URI")) - lp = new String("uri"); - else { - Debug.message( - "CLNT:pmInstPr:gui2lpprotocol: protocol is empty"); - } - return lp; - } - - public String gui2lpbanner(String p) { - String lp = null; - if (p.equals(pmUtility.getResource("Always.Print.Banner"))) - lp = new String("always"); - else if (p.equals(pmUtility.getResource("Never.Print.Banner"))) - lp = new String("never"); - else if (p.equals(pmUtility.getResource("User.Selectable.Default.On"))) - lp = new String("optional"); - else { - Debug.message( - "CLNT:pmInstPr:gui2lpbanner(): banner is empty"); - } - - if (lp != null) - Debug.message( - "CLNT:pmInstPr:gui2lpbanner(): banner is " + lp); - return lp; - - } - - public void updatePrinter() { - if (workingPrinter != null) { - if (printer != null) - workingPrinter.setPrinterName(printer); - if (server != null) { - workingPrinter.setPrintServer(server); - } - if (description != null) - workingPrinter.setComment(description); - if ((port != null) && - (!port.equals(pmUtility.getResource("Not.Selected")))) - workingPrinter.setDevice(port); - if (make != null) { - workingPrinter.setMake(make); - } - if (model != null) { - workingPrinter.setModel(model); - } - if (ppd != null) { - workingPrinter.setPPD(ppd); - } - - workingPrinter.setUsePPD(usePPD); - - if (ptype != null) - workingPrinter.setPrinterType(gui2lpptype(ptype)); - if (fcontents != null) - workingPrinter.setFileContents(gui2lpfcontents(fcontents)); - if (faultn != null) - workingPrinter.setNotify(gui2lpfaultn(faultn)); - if (destination != null) - workingPrinter.setDestination(destination); - if (protocol != null) - workingPrinter.setProtocol(gui2lpprotocol(protocol)); - if (useraccesslist != null) - workingPrinter.setUserAllowList(useraccesslist); - else { - String[] a = new String[1]; - a[0] = new String("none"); - workingPrinter.setUserAllowList(a); - } - - if (defaultp != null) - workingPrinter.setIsDefaultPrinter(defaultp.isSelected()); - - if (banner != null) - workingPrinter.setBanner(gui2lpbanner(banner)); - - } else { - Debug.warning( - "CLNT:pmInstPr:updatePrinter(): workingPrinter null"); - } - } - - - void gatherLogs(Printer p) { - cmdLog = p.getCmdLog(); - errorLog = p.getErrorLog(); - warnLog = p.getWarnLog(); - } - - - void dumpLogs(String who) { - Debug.message(who); - Debug.message(who + " command: " + cmdLog); - Debug.message(who + " warnings: " + warnLog); - Debug.message(who + " errors: " + errorLog); - } - - - public void doAddLocal() throws pmGuiException { - - try { - getPrinterServer(); - getDescription(); - getPort(); - if ((pmMisc.isppdCachefile()) && (usePPD)) { - getMakeModelPPD(); - } else { - getTypeContents(); - } - getFault(); - getBanner(); - getUserAccess(); - updatePrinter(); - - } catch (pmIncompleteFormException ie) { - throw new pmIncompleteFormException(ie.getMessage()); - } - - - boolean exist; - boolean failed = false; - - // exists could throw an exception from the underyling cmds... - try { - exist = PrinterUtil.exists(printer, myTop.ns); - } catch (Exception e) { - throw new pmGuiException(); - } - - if (exist) { - throw new pmPrinterExistsException(); - } - - try { - workingPrinter.addLocalPrinter(); - } catch (Exception e) { - failed = true; - } finally { - gatherLogs(workingPrinter); - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("doAddLocal()"); - if (failed) - throw new pmAddPrinterFailedException(errorLog); - } - - } - - - public void doAddNetwork() throws pmGuiException { - try { - getPrinterServer(); - getDescription(); - getNetworkInfo(); - if ((pmMisc.isppdCachefile()) && (usePPD)) { - getMakeModelPPD(); - } else { - getTypeContents(); - } - getFault(); - getBanner(); - getUserAccess(); - updatePrinter(); - } catch (pmIncompleteFormException ie) { - throw new pmIncompleteFormException(ie.getMessage()); - } - - boolean exist = false; - - try { - exist = PrinterUtil.exists(printer, myTop.ns); - } catch (Exception e) { - Debug.message( - "CLNT:pmInstPr:doAddNetwork:printer exists " + e); - throw new pmGuiException(); - } - - if (exist) { - Debug.message( - "CLNT:pmInstPr:Trying to add existing printer: " + printer); - throw new pmPrinterExistsException(); - } - - boolean failed = false; - try { - workingPrinter.addLocalPrinter(); - } catch (Exception e) { - failed = true; - } finally { - gatherLogs(workingPrinter); - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("doAddNetwork()"); - if (failed) - throw new pmAddPrinterFailedException(errorLog); - } - } - - - public void doModifyLocalAttached() throws pmGuiException { - getDescription(); - getFault(); - getBanner(); - - if (workingPrinter.getPPD() != null) { - getMakeModelPPD(); - } else { - getTypeContents(); - } - getUserAccess(); - updatePrinter(); - - boolean failed = false; - try { - workingPrinter.modifyPrinter(); - } catch (Exception e) { - Debug.warning("CLNT:doModifyLocalAttached: " + e); - failed = true; - } finally { - gatherLogs(workingPrinter); - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("doModifyLocalAttached()"); - if (failed) - throw new pmModifyPrinterFailedException(errorLog); - } - - } - - public void doModifyLocalNetwork() throws pmGuiException { - getDescription(); - getNetworkInfo(); - getFault(); - getBanner(); - if (workingPrinter.getPPD() != null) { - getMakeModelPPD(); - } else { - getTypeContents(); - } - getUserAccess(); - updatePrinter(); - - boolean failed = false; - try { - workingPrinter.modifyPrinter(); - } catch (Exception e) { - Debug.warning("CLNT:pmInstPr:doModifyLocalNetwork: " + e); - failed = true; - } finally { - gatherLogs(workingPrinter); - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("doModifyLocalNetwork()"); - if (failed) - throw new pmModifyPrinterFailedException(errorLog); - } - - } - - - public void doModifyRemote() throws pmGuiException { - getDescription(); - updatePrinter(); - - boolean failed = false; - try { - workingPrinter.modifyPrinter(); - } catch (Exception e) { - Debug.warning("CLNT:doModifyRemote: " + e); - failed = true; - } finally { - gatherLogs(workingPrinter); - pmCalls.debugShowPrinter(workingPrinter); - dumpLogs("doModifyRemote()"); - if (failed) - throw new pmModifyPrinterFailedException(errorLog); - } - - } - - - public void doClearFields() { - - if (pnameText != null) - pnameText.setText(""); - if (snameText != null) - snameText.setText(""); - if (descText != null) - descText.setText(""); - if (portCombo != null) - portCombo.setSelectedIndex(0); - if (makeCombo != null) - makeCombo.setSelectedIndex(0); - if (modelCombo != null) - modelCombo.setSelectedIndex(0); - if (ppdCombo != null) - ppdCombo.setSelectedIndex(0); - if (typeCombo != null) - typeCombo.setSelectedIndex(0); - if (faultCombo != null) - faultCombo.setSelectedIndex(0); - if (protocolCombo != null) - protocolCombo.setSelectedIndex(0); - if (destText != null) - destText.setText(""); - - if (defaultp.isSelected()) - defaultp.doClick(); - - if (bannerCombo != null) - bannerCombo.setSelectedIndex(0); - - accessModel.removeListEntries(); - accessModel.addaccessList("all"); - } - - public void doResetFields() { - - if (workingPrinter != null) { - try { - if (workingPrinter.getComment() != null) - descText.setText(workingPrinter.getComment()); - else - descText.setText(""); - } catch (Exception e) { - Debug.message( - "CLNT:pmInstallPr:doResetFields(): getComment() " + - "Exception: " + e); - } - - if (action == Constants.ADDLOCAL || - action == Constants.ADDNETWORK || - action == Constants.MODIFYATTACHED) { - try { - portCombo.setSelectedItem(workingPrinter.getDevice()); - } catch (Exception e) { - Debug.message( - "CLNT:pmInsPr:doResetFields(): getDevice() " + - "Exception: " + e); - } - } - - if (action != Constants.MODIFYREMOTE) { - if (workingPrinter.getPPD() != null) { - setMake(); - setModel(); - setPPD(); - } else { - setPrinterType(); - setType(); - } - - setFault(); - - if (action == Constants.MODIFYNETWORK) - setNetworkInfo(); - - try { - accessModel.removeListEntries(); - accessModel.addaccessList( - workingPrinter.getUserAllowList()); - accessList.setListData(accessModel.getAccessList()); - accessList.ensureIndexIsVisible(0); - } catch (Exception e) { - Debug.warning( - "CLNT:InstPr:doResetFields(): addaccessList() " + - "Exception: " + e); - } finally { - accessList.clearSelection(); - } - - - - // selected and banner object out of sync - setBanner(); - } - - // selected and printer object out of sync - if ((defaultp.isSelected() && - !workingPrinter.getIsDefaultPrinter()) || - - (!defaultp.isSelected() && - workingPrinter.getIsDefaultPrinter())) - - defaultp.doClick(); - - } - } - - - - public boolean isactionModify() { - - if (action == Constants.MODIFYATTACHED || - action == Constants.MODIFYNETWORK || - action == Constants.MODIFYREMOTE) - - return true; - else - return false; - } - - public void doReset() { - Debug.message("CLNT:pmInsPr:doReset()"); - if (action == Constants.ADDLOCAL || - action == Constants.ADDNETWORK) { - - doClearFields(); - } else { - doResetFields(); - } - - // as a side effect, the OK button will regain default status - if (defaultComponent != null) - defaultComponent.requestFocus(); - } - - public void doAction() throws pmGuiException { - - // if nameservice, check for login - - if (myTop.ns.getNameService().equals("nis") == true || - myTop.ns.getNameService().equals("ldap") == true) { - try { - if (!myTop.ns.isAuth()) { - pmUtility.doLogin(myTop, frame); - } - } catch (pmUserCancelledException e) { - throw new pmLoginFailedException( - pmUtility.getResource("User.cancelled.login.")); - } catch (pmGuiException ge) { - Debug.message("CLNT:pmInstPr: Required login failed."); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource("Required.login.failed."), - myTop, - "LoginFailed"); - m.setVisible(true); - Debug.message("CLNT:pmInstPr:required login failed."); - throw new pmLoginFailedException( - pmUtility.getResource("Required.login.failed.")); - } catch (Exception e) { - Debug.message("CLNT:pmInstPr:login exception: " + e); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource("Required.login.failed."), - myTop, - "LoginFailed"); - m.setVisible(true); - throw new pmLoginFailedException( - pmUtility.getResource("Required.login.failed.")); - } - } - - frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - Debug.message("CLNT:pmInstPr:doAction: action " + action); - - // Check for confirmation option - if (((myTop.getConfirmOption() == true) && (confirmAction() == true)) - || (myTop.getConfirmOption() == false)) { - - try { - - switch (action) { - - case Constants.ADDLOCAL: - doAddLocal(); - break; - case Constants.ADDNETWORK: - doAddNetwork(); - break; - case Constants.MODIFYATTACHED: - workingPrinter.getPrinterDetails(); - Debug.message( - "CLNT:pmInstPr:Printer Details: server is " + - workingPrinter.getPrintServer()); - doModifyLocalAttached(); - break; - case Constants.MODIFYNETWORK: - // add dest and protocol - workingPrinter.getPrinterDetails(); - Debug.message("CLNT:pmInstPr:Printer Details: server is " + - workingPrinter.getPrintServer()); - doModifyLocalNetwork(); - break; - case Constants.MODIFYREMOTE: - workingPrinter.getPrinterDetails(); - doModifyRemote(); - break; - } - - } catch (pmIncompleteFormException fe) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - fe.getMessage()); // "FormError" - m.setVisible(true); - throw new pmIncompleteFormException(); - } catch (pmPrinterExistsException ee) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "The.specified.printer.already.exists.")); - m.setVisible(true); - } catch (pmNullSelectedPrinterException ne) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "The.selected.printer.does.not.exist.")); - m.setVisible(true); - cleanup(); - // frame.dispose(); - } catch (pmAddPrinterFailedException ae) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - ae.getMessage(), - myTop, - "AddPrinterFailed"); - m.setVisible(true); - - } catch (pmModifyPrinterFailedException me) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - me.getMessage(), - myTop, - "ModifyFailed"); - m.setVisible(true); - } catch (pmGuiException ge) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Application.Error"), - ge.toString()); - m.setVisible(true); - - } catch (pmCmdFailedException cfe) { - String msg = cfe.getMessage(); - if (msg == null || msg.length() == 0) - msg = pmUtility.getResource( - "error.message.command-failed"); - - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Command.Failed.Error"), - msg); - m.setVisible(true); - - } catch (Exception e) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Unknown.Application.Error"), - e.toString()); - m.setVisible(true); - - } finally { - frame.setCursor(Cursor.getDefaultCursor()); - myTop.setLogData(cmdLog, errorLog, warnLog); - myTop.showLogData(actionName); - } - - // Update the list of printers - myTop.pmsetPrinterList(); - } - - } - - public boolean confirmAction() { - if (myTop.getConfirmOption() == true) { - pmOKCancelDialog d = new pmOKCancelDialog(frame, - pmUtility.getResource("Action.Confirmation"), - pmUtility.getResource( - "Continue.action.for.this.printer?")); - d.setVisible(true); - if (d.getValue() != JOptionPane.OK_OPTION) { - pmMessageDialog m = - new pmMessageDialog( - frame, - pmUtility.getResource("Warning"), - pmUtility.getResource("Operation.Cancelled")); - m.setVisible(true); - return false; - } - } - return true; - } - - - public void actionportCombo() { - Debug.message("CLNT:pmInstPr:actionportCombo()"); - port = (String)portCombo.getSelectedItem(); - if (port.equals(pmUtility.getResource("Other..."))) { - pmOther o = new pmOther( - frame, - pmUtility.getResource("SPM:Specify.Printer.Port"), - pmUtility.getResource("Enter.printer.port.or.file"), - myTop, - "PrinterPort"); - - o.setVisible(true); - if (o.getValue() == JOptionPane.OK_OPTION) { - port = o.deviceName.getText(); - int idx = portCombo.getItemCount(); - try { - if (!port.equals("") && Valid.device(port)) { - portCombo.insertItemAt( - port, (idx > 0) ? idx -1 : idx); - portCombo.setSelectedItem(port); - } else if (!port.equals("")) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Device.missing.or.not.writeable."), - myTop, - "PrinterPort"); // "InvalidDevice" - m.setVisible(true); - if (olddevice == null) - portCombo.setSelectedIndex(0); - else - portCombo.setSelectedItem(olddevice); - } else { - if (olddevice == null) - portCombo.setSelectedIndex(0); - else - portCombo.setSelectedItem(olddevice); - } - } catch (Exception de) { - Debug.warning( - "CLNT:pmInstPr:error validating device" + de); - } - - } else { // Cancelled out of Other window - if (olddevice == null) - portCombo.setSelectedIndex(0); - else - portCombo.setSelectedItem(olddevice); - } - } - olddevice = (String)portCombo.getSelectedItem(); - if (!port.equals(pmUtility.getResource("Not.Selected"))) { - portCombo.removeItem(pmUtility.getResource("Not.Selected")); - if ((pmMisc.isppdCachefile()) && (usePPD)) { - String makemodel[] = null; - String tmake; - int idx; - String models[] = null; - int i; - - makemodel = PrinterUtil.getProbePrinter(olddevice); - if (makemodel != null) { - if ((makemodel[0] != null) && - (!makemodel[0].equals(null))) { - - idx = (makemodel[0]).indexOf(" "); - - Debug.message( - "CLNT: makemodel[0] = " + makemodel[0]); - Debug.message( - "CLNT: makemodel[1] = " + makemodel[1]); - - if (idx != -1) - tmake = new String(makemodel[0].substring(0, idx)); - else - tmake = new String(makemodel[0]); - - // Some Manufacturers have multiple names - // Collapse them - if ((tmake.equals("hp")) || - (tmake.equals("Hewlett-Packard")) || - (tmake.equals("HEWLETT-PACKARD"))) - tmake = new String("HP"); - - if ((tmake.equals("MINOLTA-QMS")) || - (tmake.equals("MINOLTA"))) - tmake = new String("Minolta"); - - if ((tmake.equals("OKI")) || - (tmake.equals("OKI DATA CORP"))) - tmake = new String("Okidata"); - - if (tmake.equals("XEROX")) - tmake = new String("Xerox"); - - if (tmake.equals("EPSON")) - tmake = new String("Epson"); - - Debug.message("CLNT:pmInstPr:Probe:make: " + tmake); - - if ((makemodel[1] != null) && - (!makemodel[1].equals(null))) { - - Debug.message( - "CLNT:pmInstPr:Probe:model: " + makemodel[1]); - - try { - models = PrinterUtil.getModelsList( - tmake.trim()); - } catch (Exception e) { - Debug.warning( - "CLNT:pmInstPr:getModelsList: exception" + e); - } - - boolean havemodel = false; - boolean addmake = false; - - if (models == null) { - Debug.warning( - "CLNT:pmInstPr:Probe:no models for " - + tmake); - } else { - for (i = 0; i < models.length; i++) { - if (models[i].equalsIgnoreCase( - makemodel[1].trim())) { - havemodel = true; - } - } - // Some Printers do not preceed the model - // name with the Make. If fail, try adding - // Make to front of model - if (!havemodel) { - for (i = 0; i < models.length; i++) { - if (models[i].equalsIgnoreCase( - tmake.trim() + - " " + makemodel[1].trim())) { - havemodel = true; - addmake = true; - - } - } - } - - if (havemodel) { - makeCombo.setSelectedItem(tmake); - if (!addmake) { - modelCombo.setSelectedItem(makemodel[1]); - Debug.message("CLNT:pmInstPr:model is " + - makemodel[1]); - } else { - modelCombo.setSelectedItem(tmake.trim() + - " " + makemodel[1]); - Debug.message("CLNT:pmInstPr:model is " + - tmake.trim() + " " + makemodel[1]); - } - - } - } - } - } - } - } - } - } - - public void actiontypeCombo() { - - Debug.message("CLNT:pmInstPr:actiontypeCombo()"); - ptype = (String)typeCombo.getSelectedItem(); - - if (ptype.equals(pmUtility.getResource("Other..."))) { - pmOther o = new pmOther( - frame, - pmUtility.getResource("SPM:Specify.Printer.Type"), - pmUtility.getResource("Enter.printer.type:"), - myTop, - "PrinterType"); - o.setVisible(true); - if (o.getValue() == JOptionPane.OK_OPTION) { - ptype = o.deviceName.getText(); - int idx = typeCombo.getItemCount(); - try { - if (!ptype.equals("") && Valid.printerType(ptype)) { - typeCombo.insertItemAt( - ptype, (idx > 0) ? idx -1 : idx); - typeCombo.setSelectedItem(ptype); - } else if (!ptype.equals("")) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Invalid.printer.type."), - myTop, - "PrinterType"); - m.setVisible(true); - if (oldptype == null) - typeCombo.setSelectedIndex(0); - else - typeCombo.setSelectedItem(oldptype); - } else { - if (oldptype == null) - typeCombo.setSelectedIndex(0); - else - typeCombo.setSelectedItem(oldptype); - } - - } catch (Exception pte) { - Debug.message( - "CLNT:pmInstPr:error validating printertype" - + pte); - } - - } else { // Cancelled out of Other window - if (oldptype == null) - typeCombo.setSelectedIndex(0); - else - typeCombo.setSelectedItem(oldptype); - } - } - oldptype = (String)typeCombo.getSelectedItem(); - } - - // Printer make has been selected - public void actionmakeCombo() { - int i; - - make = (String)makeCombo.getSelectedItem(); - if (!make.equals(pmUtility.getResource("Not.Selected"))) - makeCombo.removeItem(pmUtility.getResource("Not.Selected")); - - - if (!oldmake.equals(make)) - modelCombo.removeAllItems(); - - oldmake = make; - } - - - // Get Model - public void actionmodelCombo() { - int i; - String models[] = null; - - if (!oldmake.equals(make)) { - try { - models = PrinterUtil.getModelsList(make); - } catch (Exception e) { - Debug.warning( - "CLNT:pmInstPr:actionmodelCombo: exception" + e); - } - - if (models == null) { - Debug.warning( - "CLNT:pmInstPr:actionmodelCombo:no models for " - + make); - modelCombo.removeAllItems(); - modelCombo.addItem(pmUtility.getResource( - "No.Models.Found")); - } else { - for (i = 0; i < models.length; i++) - modelCombo.addItem(models[i]); - } - } - - model = (String)modelCombo.getSelectedItem(); - if (!oldmodel.equals(model)) - ppdCombo.removeAllItems(); - - oldmodel = model; - } - - - public void actionppdCombo() { - int i; - int rec = -1; - int idx = -1; - String ppds[] = null; - - if (!oldmodel.equals(model)) { - - try { - ppds = PrinterUtil.getPPDList(make, model); - - } catch (Exception e) { - Debug.warning( - "CLNT:pmInstPr:actionmodelCombo: exception" +e); - } - - // Get the ppd files list - // If a recommended ppd is in the list, display it first - if (ppds == null) { - Debug.warning( - "CLNT:pmInstPr:actionmodelCombo: no ppds for " + - make + "/" + model); - ppdCombo.addItem( - pmUtility.getResource("No.PPD.Files.Found")); - } else { - for (i = 0; i < ppds.length; i++) { - ppdCombo.addItem(ppds[i]); - rec = ppds[i].indexOf("recommended"); - if (rec != -1) - idx = i; - } - - if (idx != -1) - ppdCombo.setSelectedIndex(idx); - } - } - - ppd = (String)ppdCombo.getSelectedItem(); - - if (!ppd.equals("")) - ppdCombo.removeItem(""); - - } - - - public void actionaddButton() { - - String tmp = null; - String trimtmp; - Debug.message("CLNT:pmInstPr:actionaddButton()"); - try { - tmp = userText.getText(); - } catch (Exception e) { - Debug.message( - "CLNT:pmInstPr:actionaddButton:UserAccessList empty"); - } - - if (tmp == null || tmp.equals("") || tmp.trim().equals("")) { - Debug.message("CLNT:pmInstPr:no username to add"); - } else { - trimtmp = tmp.trim(); - if (accessModel.isduplicate(trimtmp)) - Debug.message("CLNT:pmInstPr:duplicate user"); - - else if (!Valid.user(trimtmp)) { - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource("Invalid.username")); - // "FormError" - m.setVisible(true); - - } else { - if (accessModel.getRowCount() > 0 && - (accessModel.getElementAt(0).equals("all") || - accessModel.getElementAt(0).equals("none"))) - accessModel.removeRow(0); - - if (trimtmp.equals("all") || - trimtmp.equals("none")) { - accessModel.removeListEntries(); - } - - accessModel.addaccessList(trimtmp); - accessList.setListData(accessModel.getAccessList()); - int rw = accessModel.getRowCount(); - accessList.setSelectedIndex(rw - 1); - accessList.ensureIndexIsVisible(rw -1); - } - - } - userText.setText(""); - userText.requestFocus(); - - ascrollPane.revalidate(); - ascrollPane.repaint(); - - frame.repaint(); - } - - public void actiondeleteButton() { - Debug.message("CLNT:pmInstPr:actiondeleteButton()"); - int row; - int rcount; - int idx; - - row = accessList.getSelectedIndex(); - rcount = accessModel.getRowCount(); - - if ((row >= 0 && rcount > 0) && (!accessList.isSelectionEmpty())) { - accessModel.removeRow(row); - rcount = accessModel.getRowCount(); - if (rcount != 0) { - if (row == rcount) - accessList.setSelectedIndex(row - 1); - idx = accessList.getFirstVisibleIndex(); - if (idx > 0 && idx < rcount) - accessList.ensureIndexIsVisible(idx - 1); - } - } - userText.requestFocus(); - frame.repaint(); - } - - - // For ok/cancel - public void cleanup() { - - if (action == Constants.ADDLOCAL) { - myTop.localinstallView = null; - } - - if (action == Constants.ADDNETWORK) { - myTop.networkinstallView = null; - } - - } - - public void pmScreendispose() { - frame.dispose(); - } - - public void actionokButton() { - - Debug.message("CLNT:pmInstPr:actionokButton()"); - boolean incomplete = false; - - try { - doAction(); - } catch (pmLoginFailedException le) { - // User already notified - Debug.message("CLNT:pmInstPr:pmLoginFailedException caught"); - } catch (pmIncompleteFormException fe) { - // User already notified - incomplete = true; - } catch (pmGuiException ge) { - Debug.message("CLNT:pmInstPr:login Exception, task cancelled"); - } - - if (!incomplete) { - cleanup(); - myTop.pmsetdefaultpLabel(); - Debug.message("CLNT:pmInstPr:actionokbutton(): work done"); - pmCalls.debugShowPrinter(workingPrinter); - frame.setVisible(false); - frame.repaint(); - // frame.dispose(); - myTop.scrollPane.revalidate(); - myTop.scrollPane.repaint(); - } - } - - public void actionapplyButton() { - - Debug.message("CLNT:pmInstPr:actionapplyButton()"); - - try { - doAction(); - } catch (pmLoginFailedException le) { - // User already notified - Debug.message("CLNT:pmInstPr:pmLoginFailedException caught"); - } catch (pmGuiException ge) { - Debug.message("CLNT:pmInstPr:login Exception, task cancelled"); - } - - myTop.pmsetdefaultpLabel(); - Debug.message("CLNT:pmInstPr:actionapplybutton(): work done"); - pmCalls.debugShowPrinter(workingPrinter); - myTop.scrollPane.revalidate(); - myTop.scrollPane.repaint(); - } - - - public void actionresetButton() { - Debug.message("CLNT:pmInstPr:actionresetButton()"); - doReset(); - frame.repaint(); - } - - public void actioncancelButton() { - Debug.message("CLNT:pmInstPr:actioncancelButton()"); - cleanup(); - frame.setVisible(false); - frame.repaint(); - // frame.dispose(); - } - - public void actionhelpButton() { - Debug.message("CLNT:pmInstPr:actionhelpButton()"); - myTop.showHelpItem(helpTag); - } - - public void Show() { - - Debug.message("CLNT:pmInstPr:Show()"); - frame.getContentPane().add("North", this); - frame.pack(); - frame.setVisible(true); - frame.repaint(); - - // set focus to initial field, depending on which action is tbd - // this seems to work best after pack() - - // default button is always OK, for now... - // frame.getRootPane().setDefaultButton (okButton); - okButton.setAsDefaultButton(); - - - Debug.info("Show: default comp is " + defaultComponent); - if (defaultComponent != null) { - defaultComponent.requestFocus(); - } - - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmInstallScreen.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmInstallScreen.java deleted file mode 100644 index 5527d4913b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmInstallScreen.java +++ /dev/null @@ -1,494 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - * - * pmInstallScreen.java - * Create add/modify GUI - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.Vector; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - -/* - * Screen for Installing/Modifying local and network printers - */ - -public class pmInstallScreen extends pmButtonScreen { - - pmTextField pnameText; - pmTextField snameText; - pmTextField descText; - pmTextField userText; - JComboBox portCombo; - JComboBox faultCombo; - -// For printers configured without using make/model/PPD files - JComboBox fileCombo; - JComboBox typeCombo; - -// For printers configured using make/model/PPD files - JComboBox ppdCombo; - JComboBox makeCombo; - JComboBox modelCombo; - - pmTextField destText; - JComboBox protocolCombo; - JCheckBox defaultp; - JComboBox bannerCombo; - pmButton addButton; - pmButton deleteButton; - JList userList; - Vector userData; - - public pmInstallScreen() {} - - - public void printernameLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Name:")), c); - } - public void printernameTextField(JPanel north, GridBagConstraints c) { - pnameText = new pmTextField(14); - north.add(pnameText, c); - } - public void printernameStaticField(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Server:")), c); - } - - public void servernameLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Server:")), c); - } - public void servernameTextField(JPanel north, GridBagConstraints c) { - snameText = new pmTextField(30); - north.add(snameText, c); - } - public void servernameStaticField(JPanel north, GridBagConstraints c) { - } - - public void descriptionLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Description:")), c); - } - public void descriptionField(JPanel north, GridBagConstraints c) { - descText = new pmTextField(25); - north.add(descText, c); - } - - public void printerportLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Port:")), c); - } - - public void devnullLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel("/dev/null")); - } - - public void printerportField(JPanel north, GridBagConstraints c) { - - String devices[]; - int i; - - try { - devices = PrinterUtil.getDeviceList(); - } catch (Exception e) { - Debug.warning("CLNT: pmAccess:getDeviceList caught " + e); - devices = new String[1]; - devices[0] = ""; - } - portCombo = new JComboBox(devices); - portCombo.insertItemAt(pmUtility.getResource("Not.Selected"), 0); - portCombo.setSelectedIndex(0); - - portCombo.addItem(pmUtility.getResource("Other...")); - portCombo.addActionListener(new ComboListener(Constants.PORT)); - - north.add(portCombo, c); - - } - public void printertypeLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Type:")), c); - } - public void printertypeField(JPanel north, GridBagConstraints c) { - typeCombo = new JComboBox(); - typeCombo.addItem("PostScript"); - typeCombo.addItem("HP Printer"); - typeCombo.addItem("Reverse PostScript"); - typeCombo.addItem("Epson 2500"); - typeCombo.addItem("IBM ProPrinter"); - typeCombo.addItem("Qume Sprint 5"); - typeCombo.addItem("Daisy"); - typeCombo.addItem("Diablo"); - typeCombo.addItem("Datagraphix"); - typeCombo.addItem("DEC LA100"); - typeCombo.addItem("DEC LN03"); - typeCombo.addItem("Dec Writer"); - typeCombo.addItem("Texas Instruments 800"); - typeCombo.addItem(pmUtility.getResource("Other...")); - typeCombo.addActionListener(new ComboListener(Constants.TYPE)); - north.add(typeCombo, c); - } - - public void filecontentsLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("File.Contents:")), c); - } - public void filecontentsField(JPanel north, GridBagConstraints c) { - fileCombo = new JComboBox(); - fileCombo.addItem(pmUtility.getResource("PostScript")); - fileCombo.addItem(pmUtility.getResource("ASCII")); - fileCombo.addItem( - pmUtility.getResource("Both.PostScript.and.ASCII")); - fileCombo.addItem(pmUtility.getResource("None")); - fileCombo.addItem(pmUtility.getResource("Any")); - north.add(fileCombo, c); - } - - - public void printermakeLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Make:")), c); - } - public void printermakeField(JPanel north, GridBagConstraints c) { - - String makes[]; - - try { - makes = PrinterUtil.getMakesList(); - } catch (Exception e) { - Debug.warning("CLNT: pmAccess:getMakeList caught" +e); - makes = new String[1]; - makes[0] = ""; - } - - makeCombo = new JComboBox(makes); - makeCombo.insertItemAt( - pmUtility.getResource("Not.Selected"), 0); - makeCombo.setSelectedIndex(0); - - - makeCombo.addActionListener(new ComboListener(Constants.MAKE)); - north.add(makeCombo, c); - } - - public void printermodelsLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Model:")), c); - } - - public void printermodelsField(JPanel north, GridBagConstraints c) { - String models[]; - modelCombo = new JComboBox(); - modelCombo.addItem(" "); - modelCombo.addActionListener( - new ComboListener(Constants.MODEL)); - north.add(modelCombo, c); - } - - public void ppdcontentsLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Printer.Driver:")), c); - } - public void ppdcontentsField(JPanel north, GridBagConstraints c) { - ppdCombo = new JComboBox(); - ppdCombo.addItem(" "); - ppdCombo.addActionListener(new ComboListener(Constants.PPD)); - north.add(ppdCombo, c); - } - - public void faultnotLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Fault.Notification:")), c); - } - public void faultnotField(JPanel north, GridBagConstraints c) { - faultCombo = new JComboBox(); - - faultCombo.addItem(pmUtility.getResource("Write.to.Superuser")); - faultCombo.addItem(pmUtility.getResource("Mail.to.Superuser")); - faultCombo.addItem(pmUtility.getResource("None")); - north.add(faultCombo, c); - } - - public void destinationLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Destination:")), c); - } - public void destinationField(JPanel north, GridBagConstraints c) { - destText = new pmTextField(25); - north.add(destText, c); - } - - public void protocolLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Protocol:")), c); - } - public void protocolField(JPanel north, GridBagConstraints c) { - protocolCombo = new JComboBox(); - protocolCombo.addItem("BSD"); - protocolCombo.addItem("TCP"); - protocolCombo.addItem("URI"); - north.add(protocolCombo, c); - } - - public void optionsLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Options:")), c); - } - - public void bannerLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Banner:")), c); - } - - public void optionLabel(JPanel north, GridBagConstraints c) { - north.add(new JLabel - (pmUtility.getResource("Option:")), c); - } - - public void optionsFields(JPanel north, GridBagConstraints c) { - defaultp = new JCheckBox( - pmUtility.getResource("Default.Printer")); - - north.add(defaultp, c); - - c.gridy++; - bannerCombo = new JComboBox(); - bannerCombo.addItem(pmUtility.getResource - ("Always.Print.Banner")); - bannerCombo.addItem(pmUtility.getResource - ("User.Selectable.Default.On")); - bannerCombo.addItem(pmUtility.getResource - ("Never.Print.Banner")); - - north.add(bannerCombo, c); - } - - public void defaultoptionField(JPanel north, GridBagConstraints c) { - defaultp = new JCheckBox( - pmUtility.getResource("Default.Printer")); - - north.add(defaultp, c); - } - - public void northPanelConstraints(GridBagConstraints c) { - c.weightx = c.weighty = 0.0; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - c.insets = new Insets(8, 5, 5, 5); - c.gridheight = 1; - c.gridwidth = 1; - } - - public void labelConstraints(GridBagConstraints c) { - c.weightx = c.weighty = 0.0; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - } - public void TextFieldConstraints(GridBagConstraints c) { - c.ipadx = 15; - c.fill = GridBagConstraints.HORIZONTAL; - // c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - c.weightx = c.weighty = 1.0; - } - public void comboboxConstraints(GridBagConstraints c) { - c.weightx = c.weighty = 0.0; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - } - - public void optionsConstraints(GridBagConstraints c) { - c.fill = GridBagConstraints.NONE; - c.weightx = c.weighty = 0.0; - } - - class ComboListener implements ActionListener { - int activeCombo; - - // Constructor - public ComboListener(int aCombo) - { - activeCombo = aCombo; - } - - public void actionPerformed(ActionEvent e) { - - switch (activeCombo) - { - case Constants.PORT: - actionportCombo(); - break; - - case Constants.TYPE: - actiontypeCombo(); - break; - - case Constants.MAKE: - actionmakeCombo(); - break; - - case Constants.MODEL: - actionmodelCombo(); - break; - - case Constants.PPD: - actionppdCombo(); - break; - - } - } - } - - public void actionportCombo() {} - - public void actiontypeCombo() {} - - public void actionmakeCombo() {} - - public void actionmodelCombo() {} - - public void actionppdCombo() {} - - class adddelButtonListener implements ActionListener - { - int activeButton; - - public adddelButtonListener(int aButton) - { - activeButton = aButton; - } - - public void actionPerformed(ActionEvent e) { - - switch (activeButton) - { - case Constants.ADD: - actionaddButton(); - break; - case Constants.DELETE: - actiondeleteButton(); - break; - } - } - } - - public void actionaddButton() {} - - public void actiondeleteButton() {} - - public void useraccessLabel(JPanel center, GridBagConstraints c) { - center.add(new JLabel - (pmUtility.getResource("User.Access.List:")), c); - } - - public void adButtons(GridBagConstraints c) { - - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - - addButton = new pmButton(pmUtility.getResource("Add")); - deleteButton = new pmButton(pmUtility.getResource("Delete")); - addButton.addActionListener( - new adddelButtonListener(Constants.ADD)); - deleteButton.addActionListener( - new adddelButtonListener(Constants.DELETE)); - } - - public void xxcenterPanel() { - - JPanel center = new JPanel(); - center.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.insets = new Insets(15, 15, 15, 15); - c.anchor = GridBagConstraints.WEST; - - // Create the label - c.gridx = 0; - c.gridy = 0; - c.fill = GridBagConstraints.NONE; - c.weightx = c.weighty = 0.0; - c.anchor = GridBagConstraints.NORTHWEST; - center.add(new JLabel - (pmUtility.getResource("User.Access.List:")), c); - - // Create the User Access List as JList - userList = new JList(); - JScrollPane scrollPane = new JScrollPane(); - scrollPane.getViewport().setView(userList); - - c.gridwidth = 2; - c.gridx = 1; - c.weightx = c.weighty = 1.0; - c.fill = GridBagConstraints.BOTH; - center.add(scrollPane, c); - - // Create the text field for adding users - c.gridx = 1; - c.gridy = 1; - c.ipadx = 15; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.WEST; - c.weightx = c.weighty = 1.0; - - userText = new pmTextField(25); - center.add(userText, c); - - // Create the add/delete buttons - c.gridx = 1; - c.gridy = 2; - - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - - addButton = new pmButton(pmUtility.getResource("Add")); - deleteButton = new pmButton(pmUtility.getResource("Delete")); - addButton.addActionListener( - new adddelButtonListener(Constants.ADD)); - deleteButton.addActionListener( - new adddelButtonListener(Constants.DELETE)); - - - c.gridwidth = 1; - center.add(addButton, c); - - c.gridx = 2; - center.add(deleteButton, c); - - add("Center", center); - - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLoad.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLoad.java deleted file mode 100644 index 802eb54a88..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLoad.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmLoad.java - * Load a Naming Context implementation - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - -public class pmLoad extends JPanel { - - final static int OK = 1; - final static int APPLY = 2; - final static int RESET = 3; - final static int CANCEL = 4; - final static int HELP = 5; - - final static int NIS = 6; - final static int NONE = 7; - - pmFrame frame = new pmFrame( - pmUtility.getResource("SPM:Select.Naming.Service")); - JComboBox nameserviceCombo = new JComboBox(); - pmTop mytop = null; - int resetIndex; - - pmButton okButton = null; - pmButton cancelButton = null; - pmButton resetButton = null; - pmButton helpButton = null; - - - public pmLoad(pmTop mytop) { - this.mytop = mytop; - - Debug.message("CLNT:pmLoad()"); - setLayout(new BorderLayout()); - resetIndex = mytop.actionindex; - - northPanel(); - southPanel(); - - - } - - public void northPanel() { - JPanel north = new JPanel(); - north.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - c.weightx = c.weighty = 0.0; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - c.insets = new Insets(15, 15, 5, 15); - c.gridheight = 1; - c.gridwidth = 1; - - c.gridy = 1; - c.gridx = 0; - north.add(new JLabel - (pmUtility.getResource("Naming.Service:")), c); - - c.gridy = 1; - c.gridx = 2; - c.ipadx = 15; - - nameserviceCombo.addItem("files"); - - if (mytop.nisns != null) - nameserviceCombo.addItem("NIS"); - - if (mytop.ldapns != null) - nameserviceCombo.addItem("LDAP"); - - nameserviceCombo.setSelectedIndex(mytop.actionindex); - north.add(nameserviceCombo, c); - - nameserviceCombo.addActionListener(new nsListener()); - nameserviceCombo.addItemListener(mytop.new topnsListener()); - - add("North", north); - - } - - class nsListener implements ActionListener { - public nsListener() {} - - public void actionPerformed(ActionEvent e) - { - mytop.actionindex = nameserviceCombo.getSelectedIndex(); - if (mytop.actionindex == 0) { - Debug.message("CLNT:pmLoad:0: NONE"); - } else if (mytop.actionindex == 1) { - Debug.message("CLNT:pmLoad:1: NIS"); - } else if (mytop.actionindex == 4) { - Debug.message("CLNT:pmLoad:2: LDAP"); - } - }; - } - - public void southPanel() { - JPanel south = new JPanel(); - - south.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.gridheight = 1; - c.gridwidth = 1; - c.weightx = c.weighty = 1.0; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(15, 15, 15, 15); - c.gridy = 0; - - okButton = new pmButton( - pmUtility.getResource("OK")); - okButton.setMnemonic( - pmUtility.getIntResource("OK.mnemonic")); - - resetButton = new pmButton( - pmUtility.getResource("Reset")); - resetButton.setMnemonic( - pmUtility.getIntResource("Reset.mnemonic")); - - cancelButton = new pmButton( - pmUtility.getResource("Cancel")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Cancel.mnemonic")); - - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - - okButton.addActionListener(new ButtonListener(OK)); - resetButton.addActionListener(new ButtonListener(RESET)); - cancelButton.addActionListener(new ButtonListener(CANCEL)); - helpButton.addActionListener(new ButtonListener(HELP)); - - c.gridx = 0; - south.add(okButton, c); - c.gridx = 1; - south.add(resetButton, c); - c.gridx = 2; - south.add(cancelButton, c); - c.gridx = 3; - south.add(helpButton, c); - - add("South", south); - } - - class ButtonListener implements ActionListener { - int activeButton; - - // Constructor - public ButtonListener(int aButton) - { - activeButton = aButton; - } - - // Select Active Button and call routine - - public void actionPerformed(ActionEvent e) - { - - switch (activeButton) { - case OK: - actionokButton(); - break; - case RESET: - actionresetButton(); - break; - case CANCEL: - actioncancelButton(); - break; - case HELP: - actionhelpButton(); - break; - } - - } - } - - public void pmScreendispose() { - frame.dispose(); - } - - // Action for buttons - - public void actionokButton() { - Debug.message("CLNT:pmLoad:actionokButton()"); - mytop.pmsetNS(); - mytop.pmsetNSLabel(); - mytop.pmsetPrinterList(); - mytop.pmsetdefaultpLabel(); - frame.setVisible(false); - frame.repaint(); - frame.dispose(); - } - - public void actionresetButton() { - Debug.message("CLNT:pmLoad:actionresetButton()"); - nameserviceCombo.setSelectedIndex(resetIndex); - frame.repaint(); - } - - public void actioncancelButton() { - Debug.message("CLNT:pmLoad:actioncancelButton()"); - nameserviceCombo.setSelectedIndex(resetIndex); - frame.setVisible(false); - frame.repaint(); - frame.dispose(); - } - - public void actionhelpButton() { - Debug.message("CLNT:pmLoad:actionhelpButton()"); - mytop.showHelpItem("NameService"); - } - - public void Show() { - Debug.message("CLNT:pmLoad:Show()"); - - frame.getContentPane().add("North", this); - frame.pack(); - - // handle Esc as cancel - frame.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - actioncancelButton(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - // default button is always OK, for now... - okButton.setAsDefaultButton(); - - frame.setDefaultComponent(nameserviceCombo); - - nameserviceCombo.requestFocus(); - - frame.setVisible(true); - frame.repaint(); - - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLogDisplay.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLogDisplay.java deleted file mode 100644 index fc23e6a8c0..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLogDisplay.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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(c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmLogDisplay.java - * Command Log implementation - */ - -package com.sun.admin.pm.client; - -import javax.swing.*; - -import java.awt.*; -import java.util.*; -import java.awt.event.*; - -import com.sun.admin.pm.server.*; - -public class pmLogDisplay extends pmFrame { - - pmButton helpButton = null; - pmButton okButton = null; - pmButton clearButton = null; - pmTop theTop = null; - String helpTag = null; - JTextArea theList = null; - String theContents = null; - - public pmLogDisplay() { - this(null, null); - } - - - public pmLogDisplay(pmTop t, String h) { - super(pmUtility.getResource("SPM:Command-Line.Console")); - - theTop = t; - helpTag = h; - - setLocation(150, 200); // relative to parent frame - - // top panel - JPanel p = new JPanel(); - p.setLayout(new BorderLayout()); - - theContents = new String(); - theList = new JTextArea(12, 36); - theList.setLineWrap(false); - theList.setEditable(false); - - theList.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - copyPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, Event.CTRL_MASK), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - theList.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - copyPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - - JScrollPane scroll = new JScrollPane(); - scroll.getViewport().setView(theList); - - p.add(scroll, "Center"); - - this.getContentPane().add(p, "Center"); - - p = new JPanel(); - - okButton = new pmButton( - pmUtility.getResource("Dismiss")); - okButton.setMnemonic( - pmUtility.getIntResource("Dismiss.mnemonic")); - p.add(okButton); - - clearButton = new pmButton( - pmUtility.getResource("Clear")); - clearButton.setMnemonic( - pmUtility.getIntResource("Clear.mnemonic")); - p.add(clearButton); - - if (theTop != null && helpTag != null) { - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - p.add(helpButton); - helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - Debug.message("Help button event"); - theTop.showHelpItem(helpTag); - } - }); - } - - this.getContentPane().add(p, "South"); - - this.pack(); - - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - returnValue = JOptionPane.CLOSED_OPTION; - pmLogDisplay.this.setVisible(false); - if (pmLogDisplay.this.theTop != null) - pmLogDisplay.this.theTop.setLogOption(false); - } - }); - - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okPressed(); - } - }); - - clearButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - pmLogDisplay.this.clear(); - } - }); - - // handle Esc as dismiss in any case - getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - okPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - // getRootPane().setDefaultButton(okButton); - okButton.setAsDefaultButton(); - - theList.requestFocus(); - - } - - protected void copyPressed() { - theList.copy(); - } - - - protected void okPressed() { - returnValue = JOptionPane.OK_OPTION; - pmLogDisplay.this.setVisible(false); - if (pmLogDisplay.this.theTop != null) - pmLogDisplay.this.theTop.setLogOption(false); - } - - public int getValue() { - // Debug.message("getValue"); - return returnValue; - } - - // i.e. a solid line, or spaces, or... - public void addSeparator() { - theContents = theContents + "\n\r"; - theList.setText(theContents); - } - - // tricky: s may have embedded newlines... - public void addText(String s) { - theContents = theContents + s; - - /* - * StringTokenizer st = new StringTokenizer(s, "\n\r", false); - * try { - * while(st.hasMoreTokens()) { - * String ss = st.nextToken(); - * theContents.addElement(ss); - * } - * } catch(Exception x) { - * Debug.warning("CLNT: Log addText caught: " + x); - * } - */ - - /* - * Debug.message("Log contents len = " + theContents.size()); - * for (int i = 0; i < theContents.size(); ++i) - * Debug.message("\t" + i + ": " + theContents.elementAt(i)); - */ - - // conveniently, this forces the last line to be scrolled to. - theList.setText(theContents); - - } - - public void clear() { - theContents = null; - theContents = new String(); - theList.setText(theContents); - } - - public void disableText(boolean d) { - // theText.setEnabled(!d); - } - - public static void main(String[] args) { - JFrame f = new JFrame("Test Dialog"); - f.setSize(300, 100); - - f.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - System.exit(0); - } - }); - - f.setVisible(true); - - pmLogDisplay d = new pmLogDisplay(); - d.addText("A\nB\nC\nD\nE\nF\nG\nH\nI\nJ"); - d.setVisible(true); - } - - - protected int returnValue = JOptionPane.CLOSED_OPTION; -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLogin.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLogin.java deleted file mode 100644 index 97f3dca8b8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLogin.java +++ /dev/null @@ -1,423 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmLogin.java - * Login dialog - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.JPanel; -import javax.swing.*; -import com.sun.admin.pm.server.*; - - - -/* - * a panel dialog which captures a username and password. - */ - -public class pmLogin extends pmDialog { - private pmTop theTop = null; - private String theTag = null; - private JFrame theFrame = null; - - protected pmButton okButton = null; - protected pmButton cancelButton = null; - protected pmButton helpButton = null; - - public pmLogin(JFrame f, String title, String msg) { - this(f, title, msg, null, null); - } - - public pmLogin(JFrame f, String title, String msg, pmTop t, String h) { - - super(f, title, true); // modal - - theTop = t; - theTag = h; - theFrame = f; - - JLabel l; - JPanel p; - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.EAST; - - // top panel contains the desired message - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - l = new JLabel(msg, SwingConstants.CENTER); - p.add(l, c); - this.getContentPane().add(p, "North"); - - // NIS middle panel - // contains username and password - if (t.ns.getNameService().equals("nis")) { - - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - l = new JLabel(pmUtility.getResource("Hostname:"), - SwingConstants.RIGHT); - p.add(l, c); - - l = new JLabel(pmUtility.getResource("Username:"), - SwingConstants.RIGHT); - p.add(l, c); - - l = new JLabel(pmUtility.getResource("Password:"), - SwingConstants.RIGHT); - p.add(l, c); - - passwordField = new JPasswordField(12); - passwordField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okPressed(); - } - }); - l.setLabelFor(passwordField); - // for consistency, don't implement this until all are... - // l.setDisplayedMnemonic( - // pmUtility.getIntResource("Password.mnemonic")); - - c.gridx = 1; - c.weightx = 1.0; - - String nisMaster; - try { - nisMaster = theTop.host.getNisMaster(); - } catch (Exception e) { - nisMaster = new String("Unknown"); - Debug.warning("pmLogin: getNisMaster() returns exception: " + e); - } - - c.anchor = GridBagConstraints.WEST; - - l = new JLabel(nisMaster, SwingConstants.LEFT); - p.add(l, c); - - l = new JLabel(("root"), SwingConstants.LEFT); - p.add(l, c); - - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.gridy = GridBagConstraints.RELATIVE; - - p.add(passwordField, c); - passwordField.setEchoChar('*'); - - this.getContentPane().add(p, "Center"); - - } else if (t.ns.getNameService().equals("ldap")) { - - // middle panel contains LDAP server name, distinguished name, - // and password - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - // LDAP Server Name - l = new JLabel(pmUtility.getResource("LDAP.Server:"), - SwingConstants.RIGHT); - p.add(l, c); - - serverField = new pmTextField(25); - serverField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okPressed(); - } - }); - - String ldapMaster; - try { - ldapMaster = theTop.host.getLDAPMaster(); - } catch (Exception e) { - ldapMaster = new String(""); - Debug.warning( - "pmLdap: getLDAPMaster() returns exception: " + e); - } - - serverField.setText(ldapMaster); - c.gridx = 1; - p.add(serverField, c); - - - // Distinguished Name - c.gridx = 0; - l = new JLabel(pmUtility.getResource("Distinguished.Name:"), - SwingConstants.RIGHT); - p.add(l, c); - - dnField = new pmTextField(25); - dnField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okPressed(); - } - }); - - String defaultDN; - try { - defaultDN = theTop.host.getDefaultAdminDN(); - } catch (Exception e) { - defaultDN = new String(""); - Debug.warning( - "pmLdap: getDefaultAdminDN() returns exception: " + e); - } - - dnField.setText(defaultDN); - c.gridx = 1; - p.add(dnField, c); - - // Password - c.gridx = 0; - l = new JLabel(pmUtility.getResource("Password:"), - SwingConstants.RIGHT); - p.add(l, c); - - passwordField = new JPasswordField(12); - passwordField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okPressed(); - } - }); - l.setLabelFor(passwordField); - // for consistency, don't implement this until all are... - // l.setDisplayedMnemonic( - // pmUtility.getIntResource("Password.mnemonic")); - - c.gridx = 1; - c.weightx = 1.0; - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.gridy = GridBagConstraints.RELATIVE; - - p.add(passwordField, c); - passwordField.setEchoChar('*'); - - this.getContentPane().add(p, "Center"); - - } - - - // bottom panel contains buttons - c.gridx = 0; - c.weightx = 1.0; - c.weighty = 0.0; - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - - JPanel thePanel = new JPanel(); - - okButton = new pmButton( - pmUtility.getResource("OK")); - okButton.setMnemonic( - pmUtility.getIntResource("OK.mnemonic")); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okPressed(); - } - }); - thePanel.add(okButton, c); - - cancelButton = new pmButton( - pmUtility.getResource("Cancel")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Cancel.mnemonic")); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelPressed(); - } - }); - thePanel.add(cancelButton, c); - - if (theTag != null && theTop != null) { - - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - p.add(helpButton); - helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - helpPressed(); - } - }); - thePanel.add(helpButton, c); - } - - this.getContentPane().add(thePanel, "South"); - - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - returnValue = JOptionPane.CLOSED_OPTION; - pmLogin.this.setVisible(false); - } - }); - - // handle Esc as cancel in any case - this.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - cancelPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - // lay out the dialog - this.pack(); - - // set focus and defaults after packing... - // this.getRootPane().setDefaultButton(okButton); - okButton.setAsDefaultButton(); - - passwordField.requestFocus(); - } - - public int getValue() { - return returnValue; - } - - public void getLDAPServer() throws pmIncompleteFormException { - // LDAP Server name is required - String LDAPserver = null; - LDAPserver = serverField.getText(); - if (LDAPserver.equals("")) { - serverField.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("LDAP.server.name.required.")); - } - } - - public void getLDAPDN() throws pmIncompleteFormException { - // LDAP Distinguished name is required - String LDAPdn = null; - LDAPdn = dnField.getText(); - if (LDAPdn.equals("")) { - dnField.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("LDAP.Distinguished.name.required.")); - } - } - - public void getLDAPPassword() throws pmIncompleteFormException { - - // LDAP password is required - - String tmpp = new String(passwordField.getPassword()); - String LDAPpass = new String(tmpp.trim()); - - if (LDAPpass.equals("")) { - passwordField.requestFocus(); - throw new pmIncompleteFormException( - pmUtility.getResource("LDAP.Password.required.")); - } - } - - public void okPressed() { - - // For LDAP, Check Server, Distinguished Name and Password - boolean complete = true; - - if (theTop.ns.getNameService().equals("ldap")) { - complete = false; - try { - getLDAPServer(); - getLDAPDN(); - getLDAPPassword(); - complete = true; - } catch (pmIncompleteFormException fe) { - pmMessageDialog m = new pmMessageDialog( - theFrame, - pmUtility.getResource("Error"), - fe.getMessage()); // "FormError" - m.setVisible(true); - } - } - - if (complete) { - returnValue = JOptionPane.OK_OPTION; - pmLogin.this.setVisible(false); - } - } - - - - public void cancelPressed() { - returnValue = JOptionPane.CANCEL_OPTION; - pmLogin.this.setVisible(false); - } - - - public void clearPressed() { - - passwordField.setText(""); - } - - public void helpPressed() { - theTop.showHelpItem(theTag); - } - - public static void main(String[] args) { - JFrame f = new JFrame("Password test"); - - f.setSize(300, 100); - f.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - System.exit(0); - } - }); - f.setVisible(true); - - while (true) { - pmLogin d = new pmLogin(f, "Test Login", - "NIS/LDAP Authentication."); - d.setVisible(true); - - - } - // System.exit(0); - } - - public JPasswordField passwordField = null; - public pmTextField serverField = null; - public pmTextField dnField = null; - - protected int returnValue = JOptionPane.CLOSED_OPTION; - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLoginFailedException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLoginFailedException.java deleted file mode 100644 index 2c769eeb37..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmLoginFailedException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmLoginFailedException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmLoginFailedException extends pmGuiException { - public pmLoginFailedException(String s) { - super(s); - } - public pmLoginFailedException() { - super(); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmMessageDialog.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmMessageDialog.java deleted file mode 100644 index 8f46a3f3e8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmMessageDialog.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmMessageDialog.java - * Common info message dialog - */ - -package com.sun.admin.pm.client; - -import javax.swing.*; -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import com.sun.admin.pm.server.*; - -public class pmMessageDialog extends pmDialog { - - pmButton helpButton = null; - pmButton okButton = null; - JList theText = null; - pmTop theTop = null; - String helpTag = null; - - - public pmMessageDialog(String title, String msg) { - this(null, title, msg, null, null); - } - - public pmMessageDialog(Frame f, String title, String msg) { - this(f, title, msg, null, null); - } - - public pmMessageDialog(Frame f, - String title, - String msg, - pmTop top, - String h) { - - super(f, title, true); // modal - - theTop = top; - helpTag = h; - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.EAST; - - // top panel - JPanel p = new JPanel(); - p.setLayout(new GridBagLayout()); - // p.setLayout(new BoxLayout(BoxLayout.X_AXIS)); - - // JLabel label = new JLabel(msg, SwingConstants.CENTER); - JList theText = new JList() { - public boolean isFocusable() { - return false; - } - }; - - Vector v = new Vector(); - - Debug.message("CLNT: MessageDialog: " + title + " , " + msg); - - if (msg != null) { - StringTokenizer st = new StringTokenizer(msg, "\n", false); - try { - while (st.hasMoreTokens()) - v.addElement(st.nextToken()); - } catch (Exception x) { - Debug.warning("CLNT: pmMessageDialog caught " + x); - } - theText.setListData(v); - } - - theText.setBackground(p.getBackground()); - - // p.add(theText, "Center"); - p.add(theText, c); - - this.getContentPane().add(p, "Center"); - - okButton = new pmButton( - pmUtility.getResource("Dismiss")); - okButton.setMnemonic( - pmUtility.getIntResource("Dismiss.mnemonic")); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - actionOKButton(); - } - }); - - // handle Esc as dismiss in any case - this.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - actionOKButton(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - p = new JPanel(); - p.add(okButton); - - if (theTop != null && helpTag != null) { - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - p.add(helpButton); - helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - theTop.showHelpItem(helpTag); - } - }); - } - - this.getContentPane().add(p, "South"); - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - actionOKButton(); - } - }); - - this.pack(); - - // this.getRootPane().setDefaultButton(okButton); - okButton.setAsDefaultButton(); - - // okButton.requestFocus(); - okButton.grabFocus(); - - } - - - protected void actionOKButton() { - returnValue = JOptionPane.OK_OPTION; - pmMessageDialog.this.setVisible(false); - } - - - public int getValue() { - return returnValue; - } - - - public static void main(String[] args) { - JFrame f = new JFrame("Test Dialog"); - f.setSize(300, 100); - - f.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - System.exit(0); - } - }); - - f.setVisible(true); - - while (true) { - System.out.println("creating a new dialog instance..."); - pmMessageDialog d = - new pmMessageDialog(null, - "Dialog Test", - "Dumb test message.", - null, - null); - d.setVisible(true); - System.out.println("Dialog returns " + d.getValue()); - - d.dispose(); - - } - - } - - - protected int returnValue = JOptionPane.CLOSED_OPTION; -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmModifyPrinterFailedException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmModifyPrinterFailedException.java deleted file mode 100644 index 007c10e77d..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmModifyPrinterFailedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmModifyPrinterFailedException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmModifyPrinterFailedException extends pmGuiException { - public pmModifyPrinterFailedException(String s) { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmMustBeRemoteServerException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmMustBeRemoteServerException.java deleted file mode 100644 index 670e3df4b8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmMustBeRemoteServerException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmDeleteFailedException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmMustBeRemoteServerException extends pmGuiException { - public pmMustBeRemoteServerException(String s) { - super(s); - } - public pmMustBeRemoteServerException() { - super(); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmNeedPPDCacheException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmNeedPPDCacheException.java deleted file mode 100644 index 2f2265070a..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmNeedPPDCacheException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmInstallPrinter.java - * Install and Modify Printer implementation - * - * pmNeedPPDCache.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -public class pmNeedPPDCacheException extends pmGuiException { - public pmNeedPPDCacheException(String s) { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmNullSelectedPrinterException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmNullSelectedPrinterException.java deleted file mode 100644 index 943e5cdeb7..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmNullSelectedPrinterException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmNullSelectedPrinterException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmNullSelectedPrinterException extends pmGuiException { - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmOKCancelDialog.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmOKCancelDialog.java deleted file mode 100644 index 4bffb3733a..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmOKCancelDialog.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmOKCancelDialog.java - * Common dialog - */ - -package com.sun.admin.pm.client; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import com.sun.admin.pm.server.Debug; - - -public class pmOKCancelDialog extends pmDialog { - private pmTop theTop; - private String theTag; - protected boolean defaultIsOK = true; - - public pmOKCancelDialog(Frame f, String title, String msg) { - this(f, title, msg, null, null, true); - } - - public pmOKCancelDialog(Frame f, String title, String msg, boolean ok) { - this(f, title, msg, null, null, ok); - } - - public pmOKCancelDialog(Frame f, String title, String msg, - pmTop t, String h) { - this(f, title, msg, t, h, true); - } - - public pmOKCancelDialog(Frame f, String title, String msg, - pmTop t, String h, boolean ok) { - super(f, title, true); // modal - - theTop = t; - theTag = h; - defaultIsOK = ok; - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.EAST; - - // top panel - JPanel p = new JPanel(); - p.setLayout(new GridBagLayout()); - - JLabel label = new JLabel(msg, SwingConstants.CENTER); - p.add(label, c); - - this.getContentPane().add(p, "Center"); - - this.getContentPane().add( - buttonPanel(defaultIsOK, theTop != null && theTag != null), - "South"); - - this.pack(); - - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - returnValue = JOptionPane.CLOSED_OPTION; - pmOKCancelDialog.this.setVisible(false); - } - }); - - if (defaultIsOK) { - // this.getRootPane().setDefaultButton(okButton); - okButton.setAsDefaultButton(); - okButton.requestFocus(); - } else { - // this.getRootPane().setDefaultButton(cancelButton); - cancelButton.setAsDefaultButton(); - cancelButton.requestFocus(); - } - - // handle Esc as cancel in any case - this.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - actionCancelButton(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - } - - public JPanel buttonPanel(boolean okDefault, boolean useHelp) { - JPanel panel = new JPanel(); - - panel.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.gridheight = 1; - c.gridwidth = 1; - c.weightx = c.weighty = 0.0; - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridy = 0; - - - if (okDefault) - c.gridx = 0; - else - c.gridx = 1; - - okButton = new pmButton( - pmUtility.getResource("OK")); - okButton.setMnemonic( - pmUtility.getIntResource("OK.mnemonic")); - - if (okDefault) - c.gridx = 1; - else - c.gridx = 0; - - cancelButton = new pmButton( - pmUtility.getResource("Cancel")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Cancel.mnemonic")); - - helpButton = null; - - if (useHelp) { - c.gridx = 2; - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - } - - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - actionOKButton(); - } - }); - - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - actionCancelButton(); - } - }); - - if (helpButton != null) { - helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - theTop.showHelpItem(theTag); - } - }); - } - - c.insets = new Insets(15, 15, 15, 15); - c.gridx = 0; - panel.add(okButton, c); - c.gridx = 1; - panel.add(cancelButton, c); - c.gridx = 2; - if (helpButton != null) - panel.add(helpButton, c); - - return panel; - } - - protected void actionOKButton() { - returnValue = JOptionPane.OK_OPTION; - pmOKCancelDialog.this.setVisible(false); - } - - protected void actionCancelButton() { - returnValue = JOptionPane.CANCEL_OPTION; - pmOKCancelDialog.this.setVisible(false); - } - - - - public int getValue() { - return returnValue; - } - - - public static void main(String[] args) { - JFrame f = new JFrame("Test Dialog"); - f.setSize(300, 100); - - f.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - System.exit(0); - } - }); - - f.setVisible(true); - - while (true) { - System.out.println("creating a new dialog instance..."); - pmOKCancelDialog d = - new pmOKCancelDialog( - null, "Dialog Test", "Some message.", false); - d.setVisible(true); - System.out.println("Dialog returns " + d.getValue()); - - d.dispose(); - - } - - } - - - pmButton helpButton = null; - pmButton okButton = null; - pmButton cancelButton = null; - - protected int returnValue = JOptionPane.CLOSED_OPTION; -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmOther.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmOther.java deleted file mode 100644 index 230e398a04..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmOther.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmOther.java - * - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.JPanel; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * panel dialog which captures "other" - */ - -public class pmOther extends pmDialog { - - private pmTop theTop; - private String theTag; - pmButton okButton = null; - pmButton cancelButton = null; - pmButton helpButton = null; - - public pmOther(JFrame f, String title, String msg) { - this(f, title, msg, null, null); - } - - public pmOther(JFrame f, String title, String msg, pmTop t, String h) { - - super(f, title, true); // modal - - theTop = t; - theTag = h; - - JLabel l; - pmButton b; - JPanel p; - - Debug.message("CLNT:pmOther()"); - - // initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = GridBagConstraints.RELATIVE; - c.gridwidth = 1; - c.gridheight = 1; - c.insets = new Insets(10, 10, 5, 10); - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1.0; - - // top panel contains the message - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - l = new JLabel(msg, SwingConstants.LEFT); - p.add(l, c); - this.getContentPane().add(p, "North"); - - c.insets = new Insets(5, 10, 5, 10); - - // middle panel contains "other" text field - p = new JPanel(); - p.setLayout(new GridBagLayout()); - - deviceName.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okPressed(); - } - }); - - l.setLabelFor(deviceName); - - c.gridx = 1; - c.gridy = 0; - c.weightx = 1.0; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - - p.add(deviceName, c); - - c.gridy = GridBagConstraints.RELATIVE; - - this.getContentPane().add(p, "Center"); - - // bottom panel contains buttons - c.gridx = 0; - c.weightx = 1.0; - c.weighty = 0.0; - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = new Insets(5, 10, 10, 10); - - JPanel thePanel = new JPanel(); - okButton = new pmButton( - pmUtility.getResource("OK")); - okButton.setMnemonic( - pmUtility.getIntResource("OK.mnemonic")); - thePanel.add(okButton, c); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - okPressed(); - } - }); - - cancelButton = new pmButton( - pmUtility.getResource("Cancel")); - cancelButton.setMnemonic( - pmUtility.getIntResource("Cancel.mnemonic")); - thePanel.add(cancelButton, c); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelPressed(); - } - }); - - if (theTop != null && theTag != null) { - helpButton = new pmButton( - pmUtility.getResource("Help")); - helpButton.setMnemonic( - pmUtility.getIntResource("Help.mnemonic")); - thePanel.add(helpButton, c); - helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - theTop.showHelpItem(theTag); - } - }); - } - - - this.getContentPane().add(thePanel, "South"); - - // lay out the dialog - this.pack(); - - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - returnValue = JOptionPane.CLOSED_OPTION; - pmOther.this.setVisible(false); - } - }); - - // this.getRootPane().setDefaultButton(okButton); - okButton.setAsDefaultButton(); - - // handle Esc as cancel in any case - this.getRootPane().registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: default cancel action"); - cancelPressed(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - deviceName.requestFocus(); - - } - - public int getValue() { - return returnValue; - } - - - public void okPressed() { - Debug.message("CLNT:pmOther: " + deviceName.getText()); - returnValue = JOptionPane.OK_OPTION; - pmOther.this.setVisible(false); - } - - public void cancelPressed() { - Debug.message("CLNT:pmOther: cancelPressed"); - pmOther.this.dispose(); - } - - - public static void main(String[] args) { - JFrame f = new JFrame("Other test"); - - f.setSize(300, 100); - f.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - System.exit(0); - } - }); - f.setVisible(true); - - while (true) { - pmOther d = new pmOther(f, "Test pmOther", "Enter Printer Port"); - d.setVisible(true); - - Debug.message("CLNT:pmOther: Dialog login returns " + d.getValue()); - - } - // System.exit(0); - } - - - public pmTextField deviceName = new pmTextField(30); - protected int returnValue = JOptionPane.CLOSED_OPTION; - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmPrinterExistsException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmPrinterExistsException.java deleted file mode 100644 index 1912ab5f52..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmPrinterExistsException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmPrinterExistsException.java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmPrinterExistsException extends pmGuiException { - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmResources.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmResources.java deleted file mode 100644 index 5a5a8ec932..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmResources.java +++ /dev/null @@ -1,614 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. - * - * pmResources.java - * Localizable resource strings - */ - -package com.sun.admin.pm.client; - -import java.util.*; - -/* - * In accordance with the ResourceBundle pattern, - * each line in this file defines a tuple containing - * two strings: - * string 1 is the key used by the app -- DO NOT LOCALIZE - * string 2 is the string to be localized - * - * For example, in the tuple - * {"info_name", "Oracle Solaris Print Manager"} - * - * "info_name" is the resource key that must - * not be modified in any way - * - * "Oracle Solaris Print Manager" is the corresponding - * text to be localized - */ - -public class pmResources extends ListResourceBundle { - static final Object[][] pmBundlecontents = { - - /* - * Descriptive strings used in the 'About' dialog - */ - {"info_name", "Oracle Solaris Print Manager"}, - {"info_version", "Version 1.0"}, - {"info_authors", "Authors: Wendy Phillips"}, - - // Note: the copyright notice is displayed on two lines. - {"info_copyright1", "Copyright \251 "}, - /* JSTYLED */ - {"info_copyright2", " (c) Oracle and/or its affiliates. All rights reserved."}, - - /* - * Main window title, the application name - */ - {"Solaris.Print.Manager", "Oracle Solaris Print Manager"}, - - - /* - * Main window column labels for printer list - */ - {"Printer.Name", "Printer Name"}, - {"Printer.Server", "Printer Server"}, - {"Description", "Description"}, - - - /* - * Main window menu titles and mnemonics - */ - {"Print.Manager", "Print Manager"}, - {"Print.Manager.mnemonic", "M"}, - - {"Printer", "Printer" }, - {"Printer.mnemonic", "P"}, - - {"Tools", "Tools" }, - {"Tools.mnemonic", "T"}, - - {"Help", "Help"}, - {"Help.mnemonic", "H"}, - - - /* - * Main window data labels - */ - {"Default.Printer:", "Default Printer:"}, - {"Domain:", "Domain:"}, - {"Host:", "Host:"}, - - - /* - * 'Printer Manager' menu item labels and mnemonics - */ - {"Select.Naming.Service", "Select Naming Service..."}, - {"Select.Naming.Service.mnemonic", "N"}, - - {"Show.Command-Line.Console", "Show Command-Line Console"}, - {"Show.Command-Line.Console.mnemonic", "L"}, - - {"Confirm.All.Actions", "Confirm All Actions"}, - {"Confirm.All.Actions.mnemonic", "C"}, - - {"Use.PPD.files", "Use PPD files"}, - {"Use.PPD.files.mnemonic", "F"}, - - {"Use.localhost", "Use localhost for Printer Server"}, - {"Use.localhost.mnemonic", "U"}, - - {"Exit", "Exit"}, - {"Exit.mnemonic", "X"}, - - /* - * 'Printer' menu item labels and mnemonics - */ - {"Add.Access.to.Printer...", "Add Access to Printer..."}, - {"Add.Access.to.Printer.mnemonic", "A"}, - - {"New.Attached.Printer...", "New Attached Printer..."}, - {"New.Attached.Printer.mnemonic", "T"}, - - {"New.Network.Printer...", "New Network Printer..."}, - {"New.Network.Printer.mnemonic", "N"}, - - {"Modify.Printer.Properties...", "Modify Printer Properties..."}, - {"Modify.Printer.Properties.mnemonic", "M"}, - - {"Delete.Printer...", "Delete Printer..."}, - {"Delete.Printer.mnemonic", "D"}, - - - /* - * 'Tools' menu item labels - */ - {"Find.Printer", "Find Printer..."}, - {"Find.Printer.mnemonic", "F"}, - - - /* - * 'Help' menu item labels - */ - {"Overview", "Overview"}, - {"Overview.mnemonic", "O"}, - - {"On.Help", "On Help"}, - {"On.Help.mnemonic", "H"}, - - {"About.Print.Manager", "About Print Manager..."}, - {"About.Print.Manager.mnemonic", "A"}, - - {"Print.Manager.Settings", "Print Manager Settings"}, - {"Print.Manager.Settings.mnemonic", "P"}, - - - /* - * 'Select Naming Service' dialog title - */ - {"SPM:Select.Naming.Service", - "Oracle Solaris Print Manager: Select Naming Service"}, - - - /* - * 'Command-Line Console' dialog title - */ - {"SPM:Command-Line.Console", - "Oracle Solaris Print Manager: Command-Line Console"}, - - - /* - * 'Delete Printer' confirmation dialog title - */ - {"SPM:Delete.Printer", "Oracle Solaris Print Manager: Delete Printer"}, - - - /* - * 'Add Access to Printer' dialog title - */ - {"SPM:Add.Access.To.Printer", - "Oracle Solaris Print Manager: Add Access to Printer"}, - - - /* - * 'Add Attached Printer' dialog title - */ - {"SPM:New.Attached.Printer", - "Oracle Solaris Print Manager: New Attached Printer"}, - - - /* - * 'Add Network Printer' dialog title - */ - {"SPM:New.Network.Printer", - "Oracle Solaris Print Manager: New Network Printer"}, - - - /* - * 'Modify Printer Properties' dialog title - */ - {"SPM:Modify.Printer.Properties", - "Oracle Solaris Print Manager: Modify Printer Properties"}, - - - /* - * 'Find Printer' dialog title - */ - {"SPM:Find.Printer", "Oracle Solaris Print Manager: Find Printer"}, - - - /* - * 'Help' dialog title - */ - {"SPM:Help", "Oracle Solaris Print Manager: Help"}, - - - /* - * 'About Print Manager' dialog title - */ - {"About.Solaris.Print.Manager", "About Oracle Solaris Print Manager"}, - - - /* - * 'User Input of Printer Port' dialog title - */ - {"SPM:Specify.Printer.Port", - "Oracle Solaris Print Manager: Specify Printer Port"}, - - - /* - * 'User Input of Printer Type' dialog title - */ - {"SPM:Specify.Printer.Type", - "Oracle Solaris Print Manager: Specify Printer Type"}, - - - /* - * 'NIS Authentication' dialog title - */ - {"NIS.Authentication", "NIS Authentication"}, - - /* - * 'LDAP Authentication' dialog title - */ - {"LDAP.Authentication", "LDAP Authentication"}, - - - /* - * 'Action Confirmation' dialog title - */ - {"Action.Confirmation", "Action Confirmation"}, - - - /* - * Button labels and mnemonics - */ - {"Apply", "Apply"}, - {"Apply.mnemonic", "P"}, - - {"Cancel", "Cancel"}, - {"Cancel.mnemonic", "C"}, - - {"Clear", "Clear"}, - {"Clear.mnemonic", "L"}, - - {"Dismiss", "Dismiss"}, - {"Dismiss.mnemonic", "D"}, - - // {"Button Help", "Help"}, - // {"Button.Help.mnemonic", "H"}, - - {"OK", "OK"}, - {"OK.mnemonic", "O"}, - - {"Reset", "Reset"}, - {"Reset.mnemonic", "R"}, - - {"Find", "Find"}, - {"Find.mnemonic", "F"}, - - {"Show", "Show"}, - {"Show.mnemonic", "S"}, - - {"Forward", "Forward"}, - {"Forward.mnemonic", "W"}, - - {"Back", "Back"}, - {"Back.mnemonic", "B"}, - - {"Add", "Add"}, - {"Add.mnemonic", "A"}, - - {"Delete", "Delete"}, - {"Delete.mnemonic", "D"}, - - - /* - * Actions performed by the application - * as displayed in the Command-Line Console - */ - {"New.Attached.Printer", "New Attached Printer"}, - {"New.Network.Printer", "New Network Printer"}, - {"Modify.Printer.Properties", "Modify Printer Properties"}, - {"Delete.Printer", "Delete Printer"}, - {"Add.Access.To.Printer", "Add Access To Printer"}, - - - /* - * Prompts: messages to user describing required input. - */ - {"Enter.name.of.printer.to.find", - "Enter the name of a printer to find:"}, - {"Please.confirm.deletion.of.printer", - "Please confirm deletion of printer "}, - {"Enter.printer.type:", "Enter printer type:"}, - {"Enter.printer.port.or.file", "Enter printer port or file:"}, - - - /* - * 'Help' dialog tabbed-pane tab selection labels - */ - {"View", "View"}, - {"Index", "Index"}, - {"Search", "Search"}, - - - /* - * 'Help' dialog prompts, labels, and mnemonics - */ - {"Help.on:", "Help on:"}, - {"See.also:", "See also:"}, - - {"Matching.entries:", "Matching entries:"}, - {"Matching.entries:.mnemonic", "M"}, - - {"Search.help.index.for:", "Search help index for: "}, - {"Search.help.index.for:.mnemonic", "S"}, - - {"Search.Results:", "Search Results:"}, - {"Search.Results:.mnemonic", "R"}, - - {"Keywords:", "Keywords: "}, - {"Keywords:.mnemonic", "K"}, - - - /* - * 'Help' dialog descriptive messages to provide - * assistance in using the features. - */ - - /* - * The following two labels create one message, displayed on - * two adjacent lines. - */ - {"To.search.the.index...", - "To search the index of help articles alphabetically,"}, - {"type.your.query.below...", - "type your query below then select the desired article."}, - - /* - * The following two labels create one message, displayed on - * two adjacent lines. - */ - {"To.find.help.articles...", - "To find help articles about a particular topic,"}, - {"enter.keywords.below...", - "enter keywords below then press the Find button."}, - - - /* - * Prompts/labels on 'Install Printer' and 'Modify Printer' dialogs - */ - {"Printer.Name:", "Printer Name:"}, - {"Printer.Server:", "Printer Server:"}, - {"Description:", "Description:"}, - {"Printer.Port:", "Printer Port:"}, - {"Not.Selected", "Not Selected"}, - {"Printer.Type:", "Printer Type:"}, - {"Printer.Driver:", "Printer Driver:"}, - {"No.PPD.Files.Found", "No PPD files found"}, - {"Printer.Make:", "Printer Make:"}, - {"Printer.Model:", "Printer Model:"}, - {"No.Models.Found", "No Models Found"}, - {"File.Contents:", "File Contents:"}, - {"Fault.Notification:", "Fault Notification:"}, - {"Destination:", "Destination:"}, - {"Protocol:", "Protocol:"}, - {"Options:", "Options:"}, - {"Banner:", "Banner:"}, - {"Options.mnemonic", "O"}, - {"Option:", "Option:"}, - {"User.Access.List:", "User Access List:"}, - - - /* - * Combo item allowing custom 'Printer Port' selection - * See "Printer.Port:" above. - */ - {"Other...", "Other..."}, - - - /* - * Combo items specifying printer 'File Contents' - * See "File.Contents" above. - */ - {"PostScript", "PostScript"}, - {"ASCII", "ASCII"}, - {"None", "None"}, - {"Any", "Any"}, - {"Both.PostScript.and.ASCII", "Both PostScript and ASCII"}, - - - /* - * Combo items specifying 'Fault Notification' options. - * See "Fault.Notification" above. - */ - {"Write.to.Superuser", "Write to Superuser"}, - {"Mail.to.Superuser", "Mail to Superuser"}, - - - /* - * Labels for checkboxes used in 'Install Printer' and - * 'Modify Printer' dialogs - */ - {"Default.Printer", "Default Printer"}, - {"Always.Print.Banner", "Always Print Banner"}, - {"User.Selectable.Default.On", "User Selectable - Default=on"}, - {"Never.Print.Banner", "Never Print Banner"}, - - - /* - * Prompt for 'Select Naming Service' combo - */ - {"Naming.Service:", "Naming Service:"}, - - - /* - * Descriptive label for 'NIS Authentication' dialog - */ - {"Enter.NIS.authentication.data.", "Enter NIS authentication data."}, - - /* - * Descriptive label for 'LDAP Authentication' dialog - */ - {"Enter.LDAP.authentication.data.", "Enter LDAP authentication data."}, - - - /* - * Prompts and mnemonics for 'NIS Authentication' dialog - */ - {"Hostname:", "Hostname:"}, - {"Hostname.mnemonic", "H"}, - - {"Username:", "Username:"}, - {"Username.mnemonic", "U"}, - - {"Password:", "Password:"}, - {"Password.mnemonic", "P"}, - - /* - * Prompts for 'LDAP Authentication' dialog - */ - {"LDAP.Server:", "LDAP Server:"}, - {"Distinguished.Name:", "Distinguished Name:"}, - {"Password:", "Password:"}, - - - /* - * Error dialog titles - */ - {"Application.Error", "Application Error"}, - {"Unknown.Application.Error", "Unknown Application Error"}, - {"Command.Failed.Error", "Command Failed Error"}, - {"Error", "Error"}, - {"Warning", "Warning"}, - - - /* - * Error messages displayed to user - */ - {"Item.not.found:", "Item not found: "}, - {"No.information.available.", "No information available."}, - {"Unable.to.find.printer", "Unable to find printer "}, - {"Printer.delete.operation.failed.", - "Printer delete operation failed."}, - {"Invalid.printer.type.", "Invalid printer type."}, - {"Device.missing.or.not.writeable.", - "Device missing or not writeable."}, - {"Printer.name.required.", "Printer name required."}, - {"Printer.Port.Selection.required", "Printer Port Selection required."}, - {"Printer.Make.Selection.required", "Printer Make Selection required."}, - {"Printer.name.invalid.", "Printer name invalid."}, - {"Server.name.required.", "Server name required."}, - {"Server.name.invalid.", "Server name invalid."}, - {"User.Cancelled.Login", "User Cancelled Login"}, - {"Destination.required.", "Destination required."}, - {"User.Cancelled.Login", "User Cancelled Login"}, - {"Destination.invalid.", "Destination invalid."}, - {"Operation.Cancelled", "Operation Cancelled"}, - {"Login.Failure", "Login Failure"}, - {"Required.login.failed.", "Required login failed."}, - {"Login.Authorization.Failed", "Login Authorization Failed"}, - {"Cannot.modify.this.queue;ppdcache.file.missing.", - "Cannot modify this queue; ppdcache file missing."}, - {"Cannot.modify.this.queue;PPD.file.not.in.ppdcache.", - "Cannot modify this queue; PPD file not in ppdcache."}, - {"Request.cannot.be.completed.", "Request cannot be completed."}, - {"Could.not.get.local.hostname", "Could not get local hostname"}, - {"The.specified.printer.already.exists.", - "The specified printer already exists."}, - {"The.server.must.be.a.remote.server.", - "The server must be a remote server."}, - {"Required.login.failed.", "Required login failed."}, - {"Invalid.printer.type.", "Invalid printer type."}, - {"Invalid.username", "Invalid username"}, - {"Device.missing.or.not.writeable.", - "Device missing or not writeable."}, - {"User.cancelled.login.", "User cancelled login."}, - {"Nothing.matched.", "Nothing matched."}, - {"The.specified.printer.already.exists.", - "The specified printer already exists."}, - {"The.selected.printer.does.not.exist.", - "The selected printer does not exist."}, - {"User.not.authorized.to.modify.this.namespace.", - "User not authorized to modify this namespace."}, - {"Cannot.get.list.of.printers.Exiting.", - "Cannot get list of printers. Exiting."}, - {"LDAP.server.name.required.", - "LDAP Server Name required."}, - {"LDAP.Distinguished.name.required.", - "LDAP Distinguished Name required."}, - {"LDAP.Password.required.", - "LDAP Password required."}, - - - /* - * Prompts for 'Confirm Action' dialogs - */ - {"Continue.action.for.this.printer?", - "Continue action for this printer?"}, - {"Continue.creating.access.for.this.printer?", - "Continue creating access for this printer?"}, - - - /* - * The help subsystem builds a database of searchable - * keywords based in part on the title of each help - * article. In order to avoid excessive false hits, the - * following words are ignored when adding title words - * to the searchable keyword list. - * - * If this list is left empty, all the words in the title of - * each help article will be added to the keywords database. - */ - {"help.ignore.words", "to an a of if the and or"}, - - - - /* - * Title for the authorization dialog which is invoked by - * the printmgr executable. - */ - {"Authentication.required", "Authentication Required"}, - - /* - * Prompt for the printmgr authorization dialog. - * This is displayed with line breaks. - */ - /* JSTYLED */ - {"Root.access.is.required", "Root access is required for full functionality.\nYou may authenticate as root or continue\nwith limited functionality."}, - - /* - * Buttons for the authorization dialog. - */ - {"Authenticate", "Authenticate"}, - {"Authenticate.mnemonic", "A"}, - - {"Continue", "Continue"}, - {"Continue.mnemonic", "N"}, - - /* - * Title for the root password request dialog invoked by printmgr. - */ - {"Root.authentication", "Root Authentication"}, - - /* - * Prompt for the root password request dialog. - */ - {"Enter.root.password", "Enter root password"}, - - /* - * Prompt for the root password request dialog. - */ - {"Invalid.password", "Invalid password entered. Retry?"}, - - /* - * Just a placeholder, never used. - */ - {"dummy", ""} - }; - - public Object[][] getContents() { - return pmBundlecontents; - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmTextField.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmTextField.java deleted file mode 100644 index a02778c907..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmTextField.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmTextField.java - * Extension of JTextField which accepts only 8-bit-ASCII. - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; - -public class pmTextField extends JTextField { - public pmTextField(int n) { - this(null, n); - } - - public pmTextField(String s) { - this(s, 0); - } - - public pmTextField(String s, int n) { - super(s, n); - } - - protected Document createDefaultModel() { - return new pmFilterDoc(); - } - - /* - * This doc implementation will disallow insertion of a - * string containing any characters which are non-8-bit-ascii. - */ - private class pmFilterDoc extends PlainDocument { - public void insertString(int offset, String str, AttributeSet a) - throws BadLocationException { - int i, c; - char[] buf = str.toCharArray(); - - for (i = 0; i < buf.length; i++) { - c = (new Character(buf[i])).charValue(); - if (c > 0x00ff) - break; - } - if (i == buf.length) - super.insertString(offset, str, a); - else - Toolkit.getDefaultToolkit().beep(); - } - } - - public static void main(String args[]) { - JFrame f = new JFrame(); - f.getContentPane().add(new pmTextField(20)); - f.pack(); - f.setVisible(true); - f.repaint(); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmTop.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmTop.java deleted file mode 100644 index 76fe55af95..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmTop.java +++ /dev/null @@ -1,1303 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmTop.java - * Top level - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.util.Vector; -import java.lang.*; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.table.AbstractTableModel; -import javax.swing.text.*; -import javax.swing.border.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * Top window for printer manager - */ - -public class pmTop extends JPanel { - - static private pmTop myTop = null; - static private pmHelpFrame helpFrame = null; - static private pmAboutBox aboutBox = null; - static private pmLogDisplay commandLog = null; - static private pmFindFrame findFrame = null; - - JLabel nameserviceLabel = new JLabel(); - JLabel domainhostLabel; - JLabel defaultpLabel; - String defaultPrinter; - JScrollPane scrollPane; - JTable listTable; - Host host = new Host(); - private JPanel north = new JPanel(); - JPanel center; - listTableModel listModel; - ListSelectionModel listSM; - - JMenuBar menuBar; - JFrame parentFrame; - JCheckBoxMenuItem logCheck; - JCheckBoxMenuItem confirmCheck; - JCheckBoxMenuItem usePPD; - JCheckBoxMenuItem useLocalhost; - JMenuItem modifyMenuItem = null; - JMenuItem deleteMenuItem = null; - - JMenuItem access; - JMenuItem local; - JMenuItem network; - - int actionindex = 0; - private String newNS; - NameService ns = null; - NameService nisns = null; - NameService systemns = null; - NameService ldapns = null; - - pmAccess accessView = null; - pmInstallPrinter localinstallView = null; - pmInstallPrinter networkinstallView = null; - pmDelete deleteView = null; - pmInstallPrinter modifyView = null; - pmLoad loadView = null; - - String clickedPrinter; - String selectedPrinter = null; - String selprinterServer = null; - int selectedRow = -1; - - String cmdLog = null; - String errorLog = null; - String warningLog = null; - - boolean runningAuth = false; - boolean isRoot = false; - - pmFrame frame; - - - public pmTop(JFrame parent) { - parentFrame = parent; - setLayout(new BorderLayout()); - pmTopInit(); - - } - - public void pmTopInit() { - - try { - systemns = new NameService("system"); - } catch (Exception e) { - Debug.message("CLNT: system:Nameservice exception " + e); - } - try { - nisns = new NameService("nis"); - } catch (Exception e) { - Debug.message("CLNT: nis:Nameservice exception " + e); - } - try { - ldapns = new NameService("ldap"); - } catch (Exception e) { - Debug.message("CLNT: ldap:Nameservice exception " + e); - } - - ns = systemns; - newNS = "files"; - - // determine root privileges - try { - ns.checkAuth(); - } catch (Exception ax) { - Debug.message("CLNT: checkAuth threw " + ax); - } - - if (ns.isAuth()) { - runningAuth = true; - isRoot = true; - Debug.message("CLNT: Running as root"); - } else - Debug.message("CLNT: Not running as root"); - - northPanel(); - centerPanel(); - southPanel(); - - } - - // Set values so that printer selection null - public void clearSelected() { - selectedPrinter = null; - selprinterServer = null; - selectedRow = -1; - enableEditMenuItems(false); - } - - - // Create north panel with GridBagLayout - public void northPanel() { - - menuBar = new JMenuBar(); - menuBar.setBorder(new EmptyBorder(5, 5, 5, 5)); - menuBar.add(appMenu()); - menuBar.add(objectMenu()); - menuBar.add(toolsMenu()); - menuBar.add(Box.createHorizontalGlue()); - menuBar.add(helpMenu()); - - parentFrame.setJMenuBar(menuBar); - } - - public class listTableModel extends AbstractTableModel { - int numColumns; - - String[] columnNames = { - pmUtility.getResource("Printer.Name"), - pmUtility.getResource("Printer.Server"), - pmUtility.getResource("Description") - - }; - - // Initialize for JTable calls from SWING classes - Vector data = new Vector(0, 0); - - public listTableModel() { - numColumns = getColumnCount(); - } - - public void insertlistTable(String rowDataList[], int numcols) { - Vector rowData = new Vector(3, 1); - data = new Vector(100, 5); - int j = 0; - - if ((rowDataList.length) <= 1) { - return; - } - - for (int i = 0; i < rowDataList.length; i = i + 3) { - rowData = new Vector(3, 1); - for (j = 0; j < 3; j++) { - rowData.addElement( - rowDataList[i + j]); - } - data.addElement(rowData); - } - } - - public void removeRow(int row) { - data.removeElementAt(row); - } - - public int getRowCount() { - return data.size(); - } - - public int getColumnCount() { - return columnNames.length; - } - - public String getColumnName(int col) { - return columnNames[col]; - } - - public Object getValueAt(int row, int col) { - Vector rowVector = (Vector)data.elementAt(row); - return rowVector.elementAt(col); - } - - public void setValueAt(String value, int row, int col) { - Vector rowVector = (Vector)data.elementAt(row); - rowVector.setElementAt(value, col); - } - - public void addRow(Vector row) { - data.addElement(row); - } - - public int findValue(String value) { - for (int i = 0; i < data.size(); i++) { - if (getValueAt(i, 0).equals(value)) - return i; - } - return -1; - } - - }; - - - // called on enter or double-click - void modifySelectedPrinter() { - - ListSelectionModel m = listTable.getSelectionModel(); - - if (m.isSelectionEmpty()) { - Debug.message("CLNT: list selection is empty"); - return; - } - - int selectedRow = m.getMinSelectionIndex(); - - Debug.message("CLNT: list row selected is " + selectedRow); - - selectedPrinter = - (String) listTable.getModel().getValueAt(selectedRow, 0); - selprinterServer = - (String)listTable.getModel().getValueAt(selectedRow, 1); - - Debug.message("CLNT: selectedPrinter is " + selectedPrinter); - - doModify(); - } - - - // Create printer list in center panel - public void centerPanel() { - - center = new JPanel(); - - listModel = new listTableModel(); - listTable = new JTable(listModel); - listTable.setColumnSelectionAllowed(false); - listTable.setRowSelectionAllowed(true); - listTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listTable.setShowGrid(false); - listTable.registerKeyboardAction(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: enter action"); - if (runningAuth) - modifySelectedPrinter(); - else - Toolkit.getDefaultToolkit().beep(); - }}, - KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), - JComponent.WHEN_IN_FOCUSED_WINDOW); - - - listTable.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - Point pt = e.getPoint(); - int rowIndex = listTable.rowAtPoint(pt); - int colIndex = listTable.columnAtPoint(pt); - int clickCount = e.getClickCount(); - - Debug.message("CLNT: getClickCount() is " + clickCount); - - if (clickCount == 2) { - if (rowIndex == -1) { - Debug.message("CLNT: clicked outside table"); - } else { - if (runningAuth) - modifySelectedPrinter(); - else - Toolkit.getDefaultToolkit().beep(); - } - } - } - }); - - // Add selection listener - ListSelectionModel rowSelectModel = listTable.getSelectionModel(); - - rowSelectModel.addListSelectionListener(new ListSelectionListener() { - - public void valueChanged(ListSelectionEvent e) { - - listSM = (ListSelectionModel)e.getSource(); - Debug.message("CLNT: listSM is " + listSM); - - if (listSM.isSelectionEmpty()) { - Debug.message("CLNT: list selection is empty"); - enableEditMenuItems(false); - } else { - selectedRow = listSM.getMinSelectionIndex(); - Debug.message( - "CLNT: list element selected" + selectedRow); - selectedPrinter = - (String)listTable.getModel().getValueAt(selectedRow, 0); - selprinterServer = - (String)listTable.getModel().getValueAt(selectedRow, 1); - Debug.message( - "CLNT: selectedPrinter is " + selectedPrinter); - enableEditMenuItems(true); - } - } - }); - - GridBagConstraints c = new GridBagConstraints(); - center.setLayout(new BorderLayout()); - - c.insets = new Insets(35, 50, 35, 50); - - try { - listModel.insertlistTable(PrinterUtil.getPrinterList(ns), - listModel.getColumnCount()); - } catch (Exception e) { - Debug.fatal("CLNT: pmTop:getPrinterList() caught " + e); - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Cannot.get.list.of.printers.Exiting."), - myTop, - "getPrinterListFailed"); - m.setVisible(true); - System.exit(-1); - } - - scrollPane = new JScrollPane(); - scrollPane.setViewportView(listTable); - - listTable.setPreferredScrollableViewportSize( - new Dimension(500, 500)); - scrollPane.getViewport().setView(listTable); - center.add(scrollPane); - add("Center", center); - } - - // Create south panel with grid layout - - public void southPanel() { - JPanel south = new JPanel(); - GridBagConstraints c = new GridBagConstraints(); - south.setLayout(new GridBagLayout()); - - // Constraints applied across all entries - c.fill = GridBagConstraints.BOTH; - c.insets = new Insets(6, 6, 6, 6); - c.gridheight = 1; - c.gridwidth = 1; - c.gridy = 1; - - // Create the labels - c.gridx = 0; - c.weightx = c.weighty = 1.0; - - try { - defaultpLabel = - new JLabel(pmUtility.getResource("Default.Printer:") + - " " + PrinterUtil.getDefaultPrinter(ns)); - - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getDefaultPrinter() caught " + e); - defaultpLabel = new JLabel( - pmUtility.getResource("Default.Printer:")); - } - - south.add(defaultpLabel, c); - - - if (newNS.startsWith("files")) { - try { - domainhostLabel = new JLabel(pmUtility.getResource( - "Host:") + " " + host.getLocalHostName()); - - nameserviceLabel.setText(" "); - - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getLocalHostName caught " + e); - } - - } else { - try { - nameserviceLabel.setText( - pmUtility.getResource("Naming.Service:") + " " + newNS); - domainhostLabel = new JLabel( - pmUtility.getResource("Domain:") + " " + - host.getDomainName()); - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getDomainName caught " + e); - } - } - - c.weightx = c.weighty = 1.0; - c.gridx = 2; - south.add(nameserviceLabel, c); - c.gridx = 3; - south.add(domainhostLabel, c); - add("South", south); - } - - - public JMenu appMenu() { - // name service - // --- - // cmd line console - // confirm all actions - // use ppd file - // --- - // exit - - JMenu appMenu = new JMenu(pmUtility.getResource("Print.Manager")); - appMenu.setMnemonic( - pmUtility.getIntResource("Print.Manager.mnemonic")); - - appMenu.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - Debug.message("CLNT: appMenu MouseListener"); - }; - }); - - JMenuItem load = new JMenuItem( - pmUtility.getResource("Select.Naming.Service"), - pmUtility.getIntResource("Select.Naming.Service.mnemonic")); - - load.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from load action"); - if (loadView != null) - loadView.setVisible(true); - else - loadView = new pmLoad(myTop); - loadView.Show(); - - }; - }); - load.setEnabled(true); - appMenu.add(load); - - appMenu.addSeparator(); - - logCheck = new JCheckBoxMenuItem( - pmUtility.getResource("Show.Command-Line.Console")); - logCheck.setMnemonic( - pmUtility.getIntResource("Show.Command-Line.Console.mnemonic")); - - logCheck.addActionListener(new AbstractAction() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from checkbox action"); - JCheckBoxMenuItem c = (JCheckBoxMenuItem) e.getSource(); - if (c.isSelected() == true) { - commandLog.setVisible(true); - } else { - commandLog.setVisible(false); - } - } - }); - - if (!runningAuth) - logCheck.setEnabled(false); - - appMenu.add(logCheck); - - confirmCheck = new JCheckBoxMenuItem( - pmUtility.getResource("Confirm.All.Actions"), false); - confirmCheck.setMnemonic( - pmUtility.getIntResource("Confirm.All.Actions.mnemonic")); - if (!runningAuth) - confirmCheck.setEnabled(false); - - appMenu.add(confirmCheck); - - usePPD = new JCheckBoxMenuItem( - pmUtility.getResource("Use.PPD.files"), true); - usePPD.setMnemonic(pmUtility.getIntResource("Use.PPD.files.mnemonic")); - - useLocalhost = new JCheckBoxMenuItem( - pmUtility.getResource("Use.localhost"), false); - useLocalhost.setMnemonic( - pmUtility.getIntResource("Use.localhost.mnemonic")); - - - if (!runningAuth) { - usePPD.setEnabled(false); - useLocalhost.setEnabled(false); - } - appMenu.add(usePPD); - appMenu.add(useLocalhost); - - appMenu.addSeparator(); - - JMenuItem exit = new JMenuItem( - pmUtility.getResource("Exit"), - pmUtility.getIntResource("Exit.mnemonic")); - - exit.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from exit action"); - System.exit(0); - }; - }); - - exit.setEnabled(true); - appMenu.add(exit); - - return appMenu; - } - - // disable everything is not running as root - public JMenu objectMenu() { - // add access to printer... - // --- - // new local printer... - // new network printer... - // --- - // delete printer - // modify properties... - - JMenu objectMenu = new JMenu( - pmUtility.getResource("Printer")); - - objectMenu.setMnemonic( - pmUtility.getIntResource("Printer.mnemonic")); - - access = new JMenuItem( - pmUtility.getResource("Add.Access.to.Printer..."), - pmUtility.getIntResource("Add.Access.to.Printer.mnemonic")); - - access.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from access action"); - if (accessView != null) - accessView.setVisible(true); - else - accessView = new pmAccess(myTop); - accessView.Show(); - }; - }); - - if (!runningAuth) - access.setEnabled(false); - - objectMenu.add(access); - objectMenu.addSeparator(); - - local = new JMenuItem( - pmUtility.getResource("New.Attached.Printer..."), - pmUtility.getIntResource("New.Attached.Printer.mnemonic")); - - local.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from localinstall action"); - if (localinstallView != null) - localinstallView.setVisible(true); - else { - try { - localinstallView = new pmInstallPrinter( - myTop, Constants.ADDLOCAL); - } catch (Exception ex) { - Debug.message("CLNT:pmTop:caught exception" + ex); - } - } - localinstallView.Show(); - }; - }); - - if (!runningAuth) - local.setEnabled(false); - - objectMenu.add(local); - - network = new JMenuItem( - pmUtility.getResource("New.Network.Printer..."), - pmUtility.getIntResource("New.Network.Printer.mnemonic")); - - network.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from networkinstall action"); - if (networkinstallView != null) - networkinstallView.setVisible(true); - else { - try { - networkinstallView = new - pmInstallPrinter(myTop, Constants.ADDNETWORK); - } catch (Exception ex) { - Debug.message("CLNT:pmTop:caught exception" + ex); - } - } - - networkinstallView.Show(); - }; - }); - - if (!runningAuth) - network.setEnabled(false); - - objectMenu.add(network); - objectMenu.addSeparator(); - - modifyMenuItem = new JMenuItem( - pmUtility.getResource("Modify.Printer.Properties..."), - pmUtility.getIntResource("Modify.Printer.Properties.mnemonic")); - - modifyMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - - Debug.message("CLNT: Modify " + selectedPrinter); - Debug.message("CLNT: Modify " + selprinterServer); - - doModify(); - }; - }); - - modifyMenuItem.setEnabled(false); - objectMenu.add(modifyMenuItem); - - deleteMenuItem = new JMenuItem( - pmUtility.getResource("Delete.Printer..."), - pmUtility.getIntResource("Delete.Printer.mnemonic")); - - deleteMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from delete action"); - if (selectedPrinter == null) { - Debug.warning("CLNT: selectedPrinter is null"); - Debug.message("CLNT: cannot call pmDelete"); - // show error window - } else { - deleteView = new pmDelete(myTop); - } - }; - }); - deleteMenuItem.setEnabled(false); - objectMenu.add(deleteMenuItem); - return objectMenu; - } - - // returns true iff name was found in the printer list - public boolean findPrinterInList(String name) { - - int row = -1; - - try { - String p = name.trim(); - row = listModel.findValue(p); - } catch (Exception ee) { - Debug.warning("CLNT: pmTop:find ActionList: caught " + ee); - } - - if (row != -1) { - selectedRow = row; - listTable.clearSelection(); - listTable.setRowSelectionInterval(row, row); - listTable.scrollRectToVisible(listTable.getCellRect(row, 0, true)); - listTable.revalidate(); - scrollPane.revalidate(); - scrollPane.repaint(); - } - return row != -1; - } - - public JMenu toolsMenu() { - - // find printer... - JMenu toolsMenu = new JMenu( - pmUtility.getResource("Tools")); - toolsMenu.setMnemonic( - pmUtility.getIntResource("Tools.mnemonic")); - - JMenuItem find = new JMenuItem( - pmUtility.getResource("Find.Printer"), - pmUtility.getIntResource("Find.Printer.mnemonic")); - find.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from find action"); - findFrame.setVisible(true); - } - }); - - toolsMenu.add(find); - return toolsMenu; - } - - // Create help Menu - - public JMenu helpMenu() { - JMenu helpMenu = new JMenu(pmUtility.getResource("Help")); - helpMenu.setMnemonic(pmUtility.getIntResource("Help.mnemonic")); - - JMenuItem ov = new JMenuItem( - pmUtility.getResource("Overview"), - pmUtility.getIntResource("Overview.mnemonic")); - ov.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - myTop.showHelpItem("Overview"); - }; - }); - - helpMenu.add(ov); - - JMenuItem on = new JMenuItem( - pmUtility.getResource("On.Help"), - pmUtility.getIntResource("On.Help.mnemonic")); - on.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - myTop.showHelpItem("HelpOnHelp"); - }; - }); - - helpMenu.add(on); - helpMenu.addSeparator(); - - JMenuItem about = new JMenuItem( - pmUtility.getResource("About.Print.Manager"), - pmUtility.getIntResource("About.Print.Manager.mnemonic")); - about.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: call from about help action"); - aboutBox.setVisible(true); - }; - }); - - helpMenu.add(about); - helpMenu.addSeparator(); - - JMenuItem settings = new JMenuItem( - pmUtility.getResource("Print.Manager.Settings"), - pmUtility.getIntResource("Print.Manager.Settings.mnemonic")); - settings.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Debug.message("CLNT: print manager settings help action"); - myTop.showHelpItem("PrintManagerSettings"); - }; - }); - - helpMenu.add(settings); - return helpMenu; - } - - public void actionPerformed(java.awt.event.ActionEvent e) { - } - - public void doModify() { - - if (modifyView != null) - modifyView.pmScreendispose(); - - try { - - if (selectedPrinter == null || selprinterServer == null) { - - } else { - - if ((host.getLocalHostName()).equals(selprinterServer) || - selprinterServer.equals("localhost")) { - - if (isNetwork()) { - - modifyView = new - pmInstallPrinter( - myTop, Constants.MODIFYNETWORK); - - } else { - modifyView = new - pmInstallPrinter( - myTop, Constants.MODIFYATTACHED); - } - - modifyView.Show(); - - } else { - - try { - modifyView = new pmInstallPrinter( - myTop, Constants.MODIFYREMOTE); - } catch (Exception e) { - Debug.message( - "CLNT:pmTop:caught exception" + e); - } - modifyView.Show(); - } - } - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getLocalHostName() caught " + e); - } - } // doModify() - - - public boolean isNetwork() { - - Printer newpr = new Printer(myTop.ns); - newpr.setPrinterName(selectedPrinter); - - try { - newpr.getPrinterDetails(); - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getPrinterDetails() caught " + e); - } - - pmCalls.debugShowPrinter(newpr); - - if (newpr.getDestination() != null) { - Debug.message("CLNT: isNetwork:getDestination " + - newpr.getDestination()); - return true; - } else { - Debug.message("CLNT: isNetwork:getDestination is null"); - return false; - } - } - - // Set the new namespace - public void pmsetNS() { - - String serverNS; - - // translate from gui to server - if (newNS.startsWith("files")) { - serverNS = new String("system"); - useLocalhost.setState(true); - } else if (newNS.equals("NIS")) { - serverNS = new String("nis"); - useLocalhost.setState(false); - } else if (newNS.equals("LDAP")) { - serverNS = new String("ldap"); - useLocalhost.setState(false); - } else { - serverNS = new String("system"); - useLocalhost.setState(true); - } - - Debug.message("CLNT: newNS: " + newNS + - "\n serverNS: " + serverNS + - "\n ns.getNameService(): " + ns.getNameService()); - - if (!serverNS.equals(ns.getNameService())) { - - if (newNS.startsWith("files")) { - useLocalhost.setState(true); - ns = systemns; - } else if (newNS.equals("NIS")) { - useLocalhost.setState(false); - ns = nisns; - } else if (newNS.equals("LDAP")) { - useLocalhost.setState(false); - ns = ldapns; - } else { - useLocalhost.setState(true); - ns = systemns; - } - } - - - // This tool is read-only unless the user is root on the - // print server. Thus, don't check for namespace authorization - // if user is not root. - - if (isRoot) { - // Check if user is authorized with this nameservice - if (ns.isAuth()) { - runningAuth = true; - } else { - // nis/ldap is a special case - // need to login to nis/ldap server - if (ns.getNameService().equals("nis") == true || - ns.getNameService().equals("ldap") == true) { - - try { - if (!ns.isAuth()) { - pmUtility.doLogin(myTop, loadView.frame); - runningAuth = true; - } - } catch (pmUserCancelledException e) { - Debug.message( - "CLNT:pmTop:user cancelled login"); - runningAuth = false; - } catch (pmGuiException e) { - Debug.message( - "CLNT:pmTop:login nis/ldap failed: " + e); - runningAuth = false; - pmMessageDialog m = new pmMessageDialog( - loadView.frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Required.login.failed."), - myTop, - "LoginFailed"); - m.setVisible(true); - } catch (Exception e) { - Debug.message( - "CLNT:pmTop:login nis/ldap failed: " + e); - runningAuth = false; - pmMessageDialog m = new pmMessageDialog( - loadView.frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "Required.login.failed."), - myTop, - "LoginFailed"); - m.setVisible(true); - } - } else { - try { - ns.checkAuth(); - runningAuth = true; - } catch (Exception ca) { - runningAuth = false; - pmMessageDialog m = new pmMessageDialog( - loadView.frame, - pmUtility.getResource("Error"), - pmUtility.getResource( - "User.not.authorized.to.modify.this.namespace."), - myTop, - "AuthorizationFailed"); - m.setVisible(true); - } - } - } - - if (!serverNS.equals(ns.getNameService())) { - deleteAllScreens(); - } - - // Change front panel as unauthorized to modify - if (!runningAuth) { - logCheck.setEnabled(false); - confirmCheck.setEnabled(false); - usePPD.setEnabled(false); - useLocalhost.setEnabled(false); - access.setEnabled(false); - local.setEnabled(false); - network.setEnabled(false); - modifyMenuItem.setEnabled(false); - deleteMenuItem.setEnabled(false); - } else { - logCheck.setEnabled(true); - confirmCheck.setEnabled(true); - access.setEnabled(true); - local.setEnabled(true); - network.setEnabled(true); - if (pmMisc.isppdCachefile()) - usePPD.setEnabled(true); - else - usePPD.setEnabled(false); - if (ns.getNameService().equals("system") == true) { - useLocalhost.setEnabled(true); - useLocalhost.setVisible(true); - } else { - useLocalhost.setVisible(false); - } - } - - } else { - runningAuth = false; - } - - - Debug.message("CLNT: NEW ns.getNameService(): " + - ns.getNameService()); - - } - - class topnsListener implements ItemListener { - public topnsListener() {} - - public void itemStateChanged(ItemEvent e) { - Debug.message("CLNT: hello from topnsListener" + e.getItem()); - if (e.getStateChange() == ItemEvent.SELECTED) { - newNS = (String)e.getItem(); - } - } - } - - public void pmsetdefaultpLabel() { - try { - defaultpLabel.setText( - pmUtility.getResource("Default.Printer:") + - " " + PrinterUtil.getDefaultPrinter(ns)); - - Debug.message( - "CLNT: pmTop:pmsetdefaultpLabel(): default printer: " + - PrinterUtil.getDefaultPrinter(ns)); - - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getDefaultPrinter() caught " + e); - } - } - - public boolean getLogOption() { - return logCheck.getState(); - } - - public void setLogOption(boolean val) { - logCheck.setState(val); - } - - public boolean getConfirmOption() { - return confirmCheck.getState(); - } - - public boolean getUsePPD() { - return usePPD.getState(); - } - - public boolean getUseLocalhost() { - return useLocalhost.getState(); - } - - public void doFind(String printer) { - } - - public void deleteAllScreens() { - - if (accessView != null) - accessView.pmScreendispose(); - accessView = null; - - if (localinstallView != null) - localinstallView.pmScreendispose(); - localinstallView = null; - - if (networkinstallView != null) - networkinstallView.pmScreendispose(); - networkinstallView = null; - - if (modifyView != null) - modifyView.pmScreendispose(); - modifyView = null; - - if (loadView != null) - loadView.pmScreendispose(); - loadView = null; - } - - - /* - * enable/disable modify and delete items - * this must be called when: - * . an existing printer is selected - * . the selection is disabled - */ - void enableEditMenuItems(boolean state) { - if (!runningAuth) - return; - modifyMenuItem.setEnabled(state); - deleteMenuItem.setEnabled(state); - } - - /* - * set the log/error state for the current operation - */ - void setLogData(String cmd, String err, String warn) { - cmdLog = cmd; - errorLog = err; - warningLog = warn; - } - - /* - * display current log state for the specified action - * if the cmdLog is empty nothing at all will be displayed! - */ - void showLogData(String actionName) { - - // Debug.info("CLNT: showLogData():actionName: " + actionName); - // Debug.info("CLNT: showLogData():cmdLog: " + cmdLog); - - if (cmdLog == null) - return; - - addToCommandLog(actionName + "\n"); - - // iterate over multiline cmds - StringTokenizer st = new StringTokenizer( - cmdLog, "\n\r", false); - while (st.hasMoreTokens()) { - addToCommandLog("% " + st.nextToken()); - addToCommandLog("\n"); - } - - if (errorLog != null) { - st = new StringTokenizer(errorLog, "\n\r", false); - while (st.hasMoreTokens()) { - addToCommandLog(st.nextToken()); - addToCommandLog("\n"); - } - } - - if (warningLog != null) { - st = new StringTokenizer(warningLog, "\n\r", false); - while (st.hasMoreTokens()) { - addToCommandLog(st.nextToken()); - addToCommandLog("\n"); - } - } - - addToCommandLog("***\n"); - } - - private void addToCommandLog(String s) { - commandLog.addText(s); - } - - public void showHelpItem(String tag) { - if (helpFrame != null) - helpFrame.showHelp(tag); - else - Toolkit.getDefaultToolkit().beep(); - } - - public void pmsetNSLabel() { - - if (newNS.startsWith("files")) { - - nameserviceLabel.setText(" "); - Debug.message("CLNT: pmsetNSLabel:nameserviceLabel is : " + - nameserviceLabel.getText()); - - try { - domainhostLabel.setText( - pmUtility.getResource("Host:") + " " + - host.getLocalHostName()); - } catch (Exception e) { - Debug.warning( - "CLNT: pmTop:getLocalHostName caught " + e); - } - - } else { - nameserviceLabel.setText( - pmUtility.getResource("Naming.Service:") + newNS); - Debug.message( - "CLNT: pmsetNSLabel:nameserviceLabel is : " + - nameserviceLabel.getText()); - - try { - domainhostLabel.setText( - pmUtility.getResource("Domain:") + " " + - host.getDomainName()); - } catch (Exception e) { - Debug.warning( - "CLNT: pmTop:getDomainName caught " + e); - } - } - } - - // Update the list of printers - // Printer list will change if nameservice changes and when user - // adds/deletes/changes printers - - public void pmsetPrinterList() { - - Debug.message("CLNT: pmsetPrinterList() ns is :" + - ns.getNameService()); - - try { - listModel.insertlistTable(PrinterUtil.getPrinterList(ns), - listModel.getColumnCount()); - } catch (Exception e) { - Debug.warning("CLNT: pmTop:getPrinterList() caught " + e); - } - - listTable.clearSelection(); - scrollPane.getViewport().setView(listTable); - scrollPane.revalidate(); - scrollPane.repaint(); - } - - - // returns -1 if error, 0 otherwise - protected static int parseArgs(String[] args) { - int rv = 0; - - for (int i = 0; i < args.length; ++i) { - if (args[i].compareTo("-debugall") == 0) - Debug.setDebugLevel(Debug.ALL); - else if (args[i].compareTo("-debugnone") == 0) - Debug.setDebugLevel(Debug.NONE); - else if (args[i].compareTo("-debugwarn") == 0) - Debug.setDebugLevel(Debug.WARNING); - else if (args[i].compareTo("-debugerr") == 0) - Debug.setDebugLevel(Debug.ERROR); - else if (args[i].compareTo("-debugfatal") == 0) - Debug.setDebugLevel(Debug.FATAL); - else if (args[i].compareTo("-debugmsg") == 0) - Debug.setDebugLevel(Debug.MESSAGE); - else if (args[i].compareTo("-debuginfo") == 0) - Debug.setDebugLevel(Debug.INFO); - } - - return rv; - } - - public static void main(String[] args) { - - if (parseArgs(args) < 0) - System.exit(-1); - - // use pmFrame to get app icon - pmFrame frame = new pmFrame(pmUtility.getResource("info_name")); - - myTop = new pmTop(frame); - - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - System.exit(0); - } - }); - - frame.getContentPane().add("Center", myTop); - frame.pack(); - frame.setVisible(true); - frame.repaint(); - - pmLoad firstload = new pmLoad(myTop); - myTop.loadView = firstload; - firstload.Show(); - - aboutBox = new pmAboutBox(); - commandLog = new pmLogDisplay(myTop, "ShowCommandConsole"); - findFrame = new pmFindFrame(myTop); - - /* - * Make sure to open the help frame after the about box, - * command log, and find frame windows have been opened. - * Otherwise it might cause null pointer exceptions as it - * takes a long time for the help frame to load. - */ - helpFrame = new pmHelpFrame(); - - } - - // disable Enter action **for all JTextFields** - static { - JTextField f = new JTextField(); - KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); - Keymap map = f.getKeymap(); - map.removeKeyStrokeBinding(enter); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmUserCancelledException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmUserCancelledException.java deleted file mode 100644 index 15ff9fb61c..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmUserCancelledException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmUserCancelledException .java - * - */ - -package com.sun.admin.pm.client; - -import java.lang.*; - -class pmUserCancelledException extends pmGuiException { - public pmUserCancelledException(String s) { - super(s); - } - public pmUserCancelledException() { - super(); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmUtility.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmUtility.java deleted file mode 100644 index dc10376dc5..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pmUtility.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * pmUtility.java - * Resource loading and utility classes - */ - -package com.sun.admin.pm.client; - -import java.awt.*; -import java.applet.*; -import java.io.*; -import java.util.*; -import javax.swing.*; - -import com.sun.admin.pm.server.*; - - -/* - * Utility class to provide common functions to the printing - * manager classes - */ - -public class pmUtility { - -/* - * Gets the localized string from the named bundle - */ - - public static String getCopyrightResource(String key) { - String keyvalue = null; - ResourceBundle bundle = null; - - - try { - bundle = ResourceBundle.getBundle( - "com.sun.admin.pm.client.pmCopyright"); - } catch (MissingResourceException e) { - Debug.fatal("Could not load pmCopyright file"); - } - - try { - keyvalue = bundle.getString(key); - } catch (MissingResourceException e) { - Debug.error("CLNT: getCopyrightResource: Missing: " + key); - keyvalue = new String("<<" + key + ">>"); - } - - return keyvalue; - } - - public static String getResource(String key) { - String keyvalue = null; - ResourceBundle bundle = null; - - - try { - bundle = ResourceBundle.getBundle( - "com.sun.admin.pm.client.pmResources"); - } catch (MissingResourceException e) { - Debug.fatal("Could not load pmResources file"); - } - - try { - keyvalue = bundle.getString(key); - } catch (MissingResourceException e) { - Debug.error("CLNT: getResource: Missing: " + key); - keyvalue = new String("<<" + key + ">>"); - } - - return keyvalue; - } - - public static int getIntResource(String key) { - int keyvalue = 0; - String s = null; - ResourceBundle bundle = null; - - try { - bundle = ResourceBundle.getBundle( - "com.sun.admin.pm.client.pmResources"); - } catch (MissingResourceException e) { - Debug.fatal("Could not load pmResources file"); - } - - try { - s = bundle.getString(key); - } catch (MissingResourceException e) { - Debug.error("Missing: " + key); - } - - Debug.message("Resource: " + key + " Value: " + s); - - if (s != null) { - try { - keyvalue = s.charAt(0); - } catch (Exception x) { - Debug.error("Resource: " + key + " threw: " + x); - } - } - - return keyvalue; - } - - public static void doLogin( - pmTop mytop, JFrame frame) throws pmGuiException { - - pmLogin l; - - if (mytop.ns.getNameService().equals("nis") || - mytop.ns.getNameService().equals("ldap")) { - - if (mytop.ns.getNameService().equals("nis")) { - - l = new pmLogin( - frame, - pmUtility.getResource("NIS.Authentication"), - pmUtility.getResource("Enter.NIS.authentication.data."), - mytop, - "NISAuthentication"); - - } else { // LDAP - - l = new pmLogin( - frame, - pmUtility.getResource("LDAP.Authentication"), - pmUtility.getResource("Enter.LDAP.authentication.data."), - mytop, - "LDAPAuthentication"); - } - - l.setVisible(true); - - if ((l.getValue() != JOptionPane.OK_OPTION) && - (l.getValue() != JOptionPane.CANCEL_OPTION)) { - - pmMessageDialog m = new pmMessageDialog( - frame, - pmUtility.getResource("Login.Failure"), - pmUtility.getResource( - "Request.cannot.be.completed.")); - m.setVisible(true); - throw new pmGuiException - ("pmAccess: Cannot create Login screen"); - } - - - if (l.getValue() == JOptionPane.CANCEL_OPTION) { - throw new pmUserCancelledException("User.Cancelled.Login"); - } else { - - // Pass data to backend - - // getPassword sends back untrimmed string that is invalid - // as a password as it's too long - String tmpp = new String(l.passwordField.getPassword()); - mytop.ns.setPasswd(tmpp.trim()); - - if (mytop.ns.getNameService().equals("ldap")) { - // setUser for binddn - mytop.ns.setUser(l.dnField.getText()); - // setNameServiceHost overloaded for LDAP server name - mytop.ns.setNameServiceHost(l.serverField.getText()); - } - - try { - mytop.ns.checkAuth(); - Debug.message("doLogin():checkauth() OK"); - } catch (Exception e) { - Debug.warning("doLogin:checkAuth()exception " + e); - throw new pmGuiException("Login.Authorization.Failed"); - } - } - - - // User has not put in printer or server - } else { - pmMessageDialog m = - new pmMessageDialog( - frame, - pmUtility.getResource("Login.Failure"), - pmUtility.getResource("Request.cannot.be.completed."), - mytop, "LoginFailed"); - - m.setVisible(true); - throw new pmGuiException("pmAccess: Cannot create Login screen"); - } - - } - - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pm_gen_copyright b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pm_gen_copyright deleted file mode 100644 index 0f8310dd38..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/pm_gen_copyright +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# This script generates the pmCopyright.java file -# which contains the copyright data needed by -# the Solaris Print Manager. The pmCopyright.java -# file is generated during a make in order to update -# the copyright with the correct date info, eliminating -# the need to update the copyright notice with every -# release. - -PMFILE=pmCopyright.java -DATE=`/usr/bin/date '+%Y'` - -/usr/bin/rm -f ${PMFILE} -/usr/bin/cat > ${PMFILE} <<END -/* - * GENERATED CODE - * - * Copyright ${DATE} Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -package com.sun.admin.pm.client; -import java.util.*; - -public class pmCopyright extends ListResourceBundle { - static final Object[][] pmHelpBundlecontents = { - - {"copyright_year", "1999-${DATE}"}, - {"dummy", ""} - }; - - public Object[][] getContents() { - return pmHelpBundlecontents; - } -} -END diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddAccess.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddAccess.rawhlp deleted file mode 100644 index 9898ecfa8e..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddAccess.rawhlp +++ /dev/null @@ -1,97 +0,0 @@ -<TITLE> Dialog: Add Access to Printer</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=AddAccess --> - -<CONTENT> - -<p> - -Use the Add Access to Printer dialog to make an installed printer -accessible to print client computers. See the printers.conf(4) man -page if you need more information about print client commands. - -<p> - -<b>Printer Name:</b> The name of the printer you wish to add access -to. The printer name must be a text string composed of uppercase or -lowercase alphabetical characters (a-z, A-Z), digits (0-9), hyphens, or -underscores. A printer name can be a maximum of 14 characters long. -<p> - -<b>Printer Server:</b> The name of the printer server the named printer is -installed on. The printer may be physically connected to -the server or it may be a network printer. - -<p> - -<b>NOTE:</b> Oracle Solaris Print Manager does not check for the validity of -Printer Name or Printer Server. - -<p> - -<b>Description:</b> [Optional] A description of the printer, including, -for example, the type and location of the printer. -<p> - -<b>Option: Default Printer:</b> If checked and no naming service is -being used, this printer is designated as the default printer for the -computer on which you are running Oracle Solaris Print Manager. If checked -and a naming service is being used, designates this as the default -printer for the naming service. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> - -</CONTENT> - -<KEYWORDS> -access "add access" description "default printer" "naming service" -"printer name" "printer server" dialog: add printer -</KEYWORDS> - -<p> - -<SEEALSO> -ToAddAccess -ToModify -ToDelete -ToInstallLocal -ToInstallNetwork -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddAccessFailed.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddAccessFailed.rawhlp deleted file mode 100644 index b0153bb465..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddAccessFailed.rawhlp +++ /dev/null @@ -1,62 +0,0 @@ -<TITLE> If Add Access Fails</TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=AddAccessFailed --> - -<CONTENT> - -<p> - -You must enter a printer name and a printer server name; the printer -server must be a remote server (not the current server). See the man -page for lpadmin(1M) for more information. - -<p> - -Display the Command-Line Console to help pinpoint where the error -may have occurred. Choose Show Command-Line Console from the Print -Manager menu to display the Command-Line Console. - -</CONTENT> - -<p> - -<KEYWORDS> -add access fail failure fails -</KEYWORDS> - -<p> - -<SEEALSO> -AddAccess -ToAddAccess -ToShowCommand -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddPrinterFailed.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddPrinterFailed.rawhlp deleted file mode 100644 index 948abce0f6..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/AddPrinterFailed.rawhlp +++ /dev/null @@ -1,68 +0,0 @@ -<TITLE> If New Printer Action Fails</TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=AddPrinterFailed --> - -<CONTENT> - -<p> - -The printer name must be a text string composed of uppercase or -lowercase alphabetical characters (a-z, A-Z), digits (0-9), hyphens, -or underscores. A printer name can be a maximum of 14 characters long. - -<p> - -Display the Command-Line Console to help pinpoint where the error -may have occurred. Choose Show Command-Line Console from the Print -Manager menu to display the Command-Line Console. See the man -page for lpadmin(1M) for more information. - -<p> - -</CONTENT> - -<p> - -<KEYWORDS> -install fail failure "new attached" "new network" new printer action -fails -</KEYWORDS> - -<p> - -<SEEALSO> -InstallLocal -InstallNetwork -ToInstallLocal -ToInstallNetwork -ToShowCommand -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/DeletePrinterFailed.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/DeletePrinterFailed.rawhlp deleted file mode 100644 index ea10c85462..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/DeletePrinterFailed.rawhlp +++ /dev/null @@ -1,56 +0,0 @@ -<TITLE> If Delete Printer Fails</TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=DeletePrinterFailed --> - -<CONTENT> - -<p> - -If the Delete printer process fails, follow the instructions in the -error dialog. If the instructions are incomplete or unclear, display -the Command-Line Console to help pinpoint where the error may have -occurred. Choose Show Command-Line Console from the Print Manager menu -to display the Command-Line Console. See the man page for lpadmin(1M) -for more information. - -<p> - -</CONTENT> - -<KEYWORDS> -delete fail failure printer fails -</KEYWORDS> - -<p> - -<SEEALSO> -ToDelete -ToShowCommand -Overview -MainWindow -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/HelpOnHelp.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/HelpOnHelp.rawhlp deleted file mode 100644 index d8286edfa8..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/HelpOnHelp.rawhlp +++ /dev/null @@ -1,127 +0,0 @@ -<TITLE> Help on Help </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=HelpOnHelp --> - -<CONTENT> - -<p> - -Oracle Solaris Print Manager help is displayed if you choose one of the help -items from the Help menu in the Print Manager main window or if you -click on a Help button in any of the Print Manager windows or dialogs. - -<p> - -<b> Viewing a help article </b> - -<p> - -When you click on a Help button or choose a help item from the Help -menu, help for the selected topic is displayed in the help viewer. See -the headings labeled Navigation, Index, and Search below for -instructions for viewing other help articles. - -<p> - -<b> Navigation </b> - -<p> - -To move around in an article, click on the scroll bar to the right of -the article text. Note that you can expand or contract the help window -by grabbing a corner with the mouse cursor and moving the mouse. See -below for instructions for viewing other help articles. - -<p> - -Back button: Click to move to the last article viewed. -<br> -Forward button: Click to move to the article viewed prior to clicking -the Back button. -<br> -See also pulldown menu: Select an item from the menu and click Show to display -the selected article. -<br> -Show button: After selecting an item from the See also menu, click Show -to display it. - -<p> - -<b> Index </b> - -<p> - -1. Click the Index tab at the top of the help window to display the index -search tool. - -<p> - -By default the Search field is blank and all help articles are listed. -To limit the index listing, enter the first letters of a help article; -the articles that start with the entered letters will be displayed as -you type. To see all the task descriptions, for instance, enter "to" -and a blank. - -<p> - -2. To view an article, double-click on it or select it and click -Show. The article is displayed in view mode. - -<p> - -<b> Search </b> - -<p> - -Click the Search tab at the top of the help window to display the -search tool. - -<p> - -Enter a word or phrase in the Keywords field and click Search. - -<p> - -All articles with the entered keyword or phrase marked as a keyword -will be displayed in the Search Results list. - -<p> - -To view an article, double-click on it or select it and click -Show. The article is displayed in view mode. - -<p> - -</CONTENT> - -<KEYWORDS> -view index search show back forward "see also" help keywords -</KEYWORDS> - -<p> - -<SEEALSO> -Overview -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallLocal.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallLocal.rawhlp deleted file mode 100644 index ff8602be43..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallLocal.rawhlp +++ /dev/null @@ -1,171 +0,0 @@ -<TITLE> Dialog: New Attached Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=InstallLocal --> - -<CONTENT> - -<p> - -Once you have physically connected the printer to the printer server, -use the New Attached Printer dialog to install the printer, which -makes the printer available for printing from the computer on which -you are running Oracle Solaris Print Manager. - -<p> - -<b> Printer Name:</b> - Specifies a unique name for the printer. The - printer name must be a text string composed of - uppercase or lowercase alphabetical characters - (a-z, A-Z), digits (0-9), hyphens, or - underscores. A printer name can be a maximum of - 14 characters long. -<p> - -<b> Printer Server:</b> This is the computer you have selected to act -as the server for print actions. You must be logged on to this -computer and be running Oracle Solaris Print Manager on it. Oracle -Solaris Print Manager sets up this system with the appropriate software to manage -local and remote printers. - -<p> -<b> Description:</b> - [Optional] Describes the printer, including the printer type and - location, possibly, or provides other information about the - printer. - -<p> - -<b> Printer Port:</b> - -Specifies the hardware port, such as /dev/term/a, that the printer is -connected to. -<p> - -<b> Printer Type:</b> - Specifies the generic name for a type of - printer. Supported printer types correspond to - items listed in the /usr/share/lib/terminfo - directories. Examples are PostScript, Daisy, and Diablo. - -<p> - -<b> File Contents:</b> - Specifies the format of files that can be - printed without any special filtering by the - print software. PostScript is the default and is - probably correct most of the time. -<p> - -<b> Fault Notification:</b> - Specifies how the superuser will be notified in - case of a printer error. - -<p> - -<b> Options: Default Printer:</b> If checked, designates this printer -as the default printer for printing jobs from the computer on which -you are running Oracle Solaris Print Manager. If you are using a naming -service, this printer will be the default printer for the naming -service, also. - -<p> - -Note that this is the last place the print subsystem looks to -determine where a particular print job will be printed; the -destination option of the lp command is the first place looked, and -other environment variables are checked before this one. See the man -page for printers.conf(4) for a full explanation of the search order. - -<p> - -<b> Options: Banner:</b> Specifies whether a banner -page will be printed between jobs. -<br> -<br> -"Aways Print Banner" stipulates that a banner will always be printed -and may not be turned off by the user. -<br> -"User Selectable - Default=on" stipulates that a banner will be printed -unless the user selects -to turn the banner off. -<br> -"Never Print Banner" stipulates that a banner will never be printed -and may not be turned on by the user. - -<p> - -<b> User Access List:</b> -Specifies the print clients that can - print to this printer. By default, all print - clients have access to this printer, as designated by the word -"all" in the list. - -<p> - -If you want to restrict its use to individual users, enter a user name -in the text field below the list and click Add. Other legal constructs -are system-name!login-ID (user "login-ID" on system "system-name"), -system-name!all (all users on system "system-name"), and all!login-ID -(user "login-ID" on all systems). Use the lpadmin(1M) command to deny -access to users. - -<p> - -To delete a user from the list, select the user in the list and click -Delete. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> -</CONTENT> - -<KEYWORDS> -install "local printer" "printer name" server description port -"printer type" "file contents" fault "fault notification" "default -printer" banner "attached printer" new nobanner dialog: new attached - -</KEYWORDS> - -<p> - -<SEEALSO> -ToInstallLocal -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallLocalPPD.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallLocalPPD.rawhlp deleted file mode 100644 index c344d43861..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallLocalPPD.rawhlp +++ /dev/null @@ -1,177 +0,0 @@ -<TITLE> Dialog: New Attached Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=InstallLocal --> - -<CONTENT> - -<p> - -Once you have physically connected the printer to the printer server, -use the New Attached Printer dialog to install the printer, which -makes the printer available for printing from the computer on which -you are running Oracle Solaris Print Manager. - -<p> - -<b> Printer Name:</b> - Specifies a unique name for the printer. The - printer name must be a text string composed of - uppercase or lowercase alphabetical characters - (a-z, A-Z), digits (0-9), hyphens, or - underscores. A printer name can be a maximum of - 14 characters long. -<p> - -<b> Printer Server:</b> This is the computer you have selected to act -as the server for print actions. You must be logged on to this -computer and be running Oracle Solaris Print Manager on it. Oracle -Solaris Print Manager sets up this system with the appropriate software to manage -local and remote printers. - -<p> -<b> Description:</b> - [Optional] Describes the printer, including the printer type and - location, possibly, or provides other information about the - printer. - -<p> - -<b> Printer Port:</b> - -Specifies the hardware port, such as /dev/term/a, that the printer is -connected to. -<p> - -<b> Printer Make:</b> - Specifies the printer make, or manufacturer. This - information is on the printer and/or in the documentation - that is delivered with the printer. -<p> - -<b> Printer Model:</b> - Specifies the printer model. This information - is found on the printer and/or in the documentation that is - delivered with the printer. -<p> - -<b> Printer Driver:</b> - Specifies the printer driver to use with this printer. The label - name followed in parentheses by one of the following letters -representing the repository in which the printer driver information resides: -U (user supplied printer information), A (administrator supplied printer -information), V (vendor supplied printer information), or S (system supplied -printer information), precedes the name of the Printer Driver. -<p> - -<b> Fault Notification:</b> - Specifies how the superuser will be notified in - case of a printer error. - -<p> - -<b> Options: Default Printer:</b> If checked, designates this printer -as the default printer for printing jobs from the computer on which -you are running Oracle Solaris Print Manager. If you are using a naming -service, this printer will be the default printer for the naming -service, also. - -<p> - -Note that this is the last place the print subsystem looks to -determine where a particular print job will be printed; the -destination option of the lp command is the first place looked, and -other environment variables are checked before this one. See the man -page for printers.conf(4) for a full explanation of the search order. - -<p> - -<b> Options: Banner:</b> Specifies whether a banner -page will be printed between jobs. -<br> -<br> -"Aways Print Banner" stipulates that a banner will always be printed -and may not be turned off by the user. -<br> -"User Selectable - Default=on" stipulates that a banner will be printed -unless the user selects -to turn the banner off. -<br> -"Never Print Banner" stipulates that a banner will never be printed -and may not be turned on by the user. - -<p> - -<b> User Access List:</b> -Specifies the print clients that can - print to this printer. By default, all print - clients have access to this printer, as designated by the word -"all" in the list. - -<p> - -If you want to restrict its use to individual users, enter a user name -in the text field below the list and click Add. Other legal constructs -are system-name!login-ID (user "login-ID" on system "system-name"), -system-name!all (all users on system "system-name"), and all!login-ID -(user "login-ID" on all systems). Use the lpadmin(1M) command to deny -access to users. - -<p> - -To delete a user from the list, select the user in the list and click -Delete. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> -</CONTENT> - -<KEYWORDS> -install "local printer" "printer name" server description port -"printer make" "printer model" "printer driver" fault "fault notification" "default -printer" banner "attached printer" new nobanner dialog: new attached - -</KEYWORDS> - -<p> - -<SEEALSO> -ToInstallLocal -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallNetwork.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallNetwork.rawhlp deleted file mode 100644 index c6d372193e..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallNetwork.rawhlp +++ /dev/null @@ -1,176 +0,0 @@ -<title> Dialog: New Network Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=InstallNetwork --> - -<CONTENT> - -<p> - -Use the New Network Printer dialog to install a network printer, -thus making the printer available for printing from the network. - -<p> - -<b> Printer Name:</b> - Specifies a unique name for the printer. The - printer name must be a text string composed of - uppercase or lowercase alphabetical characters - (a-z, A-Z), digits (0-9), hyphens, or - underscores. A printer name can be a maximum of - 14 characters long. -<p> - -<b> Printer Server:</b> This is the computer you have selected to act -as the server for print actions. You must be logged on to this -computer and be running Oracle Solaris Print Manager on it. Oracle -Solaris Print Manager sets up this system with the appropriate software to manage -local and remote printers. - -<p> -<b> Description:</b> - [Optional] Describes the printer, including the printer type and - location, possibly, or provides other information about the - printer. - -<p> - -<b> Printer Type:</b> - Specifies the generic name for a type of - printer. Supported printer types correspond to - entries in the /usr/share/lib/terminfo - directory. Examples are PostScript, Daisy, and Diablo. -<p> - -<b> File Contents:</b> - Specifies the format of files that can be - printed without any special filtering by the - print software. PostScript is the default and is - probably correct most of the time. -<p> - -<b> Fault Notification:</b> - Specifies how the superuser will be notified in - case of a printer error. - -<p> -<b> Destination:</b> -<br> -For <b>BSD</b> Protocol, the network name of the printer followed by a colon -and the printer-vendor-supplied queue name. -<br> -For <b>TCP</b> Protocol, the network name of the printer followed by a colon -and the tcp port number to connect to. -<br> -For <b>URI</b> Protocol, a printer URI to be used in connecting to the remote -printer. For example: "smb://user@printer-host/printer-name". -<p> - -<b> Protocol:</b> -The internet protocol for file transfer; choices are BSD, TCP, or URI. -<p> - -<b> Options: Default Printer:</b> If checked, this printer is -designated as the default printer for printing jobs sent to this -server. If another printer had been designated as the default printer -for the network, this printer will replace it as the default. If you -are using a naming service, this printer will be the default printer -for the naming service, also. - -<p> Note that this is the last place the print subsystem looks to -determine where a particular print job will be printed; the -destination option of the lp command is the first place looked, and -other environment variables are checked before this one. See the man -page for printers.conf(4) for a full explanation of the search order. - -<p> - -<b> Options: Banner:</b> Specifies whether a banner -page will be printed between jobs. -<br> -<br> -"Aways Print Banner" stipulates that a banner will always be printed -and may not be turned off by the user. -<br> -"User Selectable - Default=on" stipulates that a banner will be printed -unless the user selects -to turn the banner off. -<br> -"Never Print Banner" stipulates that a banner will never be printed -and may not be turned on by the user. - -<p> - -<b> User Access List:</b> -Specifies the print clients that can - print to this printer. By default, all print - clients have access to this printer, as designated by the word -"all" in the list. -<p> - -To add a user to the list, type a user name in the blank text field -below the list and click Add. Note that this user name replaces "all" -or "none" if either "all" or "none" is in the user access list. If -"all" or "none" is added as a user, "all" or "none" will replace the -names in the list. - -<p> - -To delete a user from the list, select the user in the list and click -Delete. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> - -</CONTENT> - -<KEYWORDS> - -install "network printer" "printer name" server description port -"printer type" "file contents" fault "fault notification" "default -printer" banner new dialog: network printer - -</KEYWORDS> - -<p> - -<SEEALSO> -ToInstallNetwork -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallNetworkPPD.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallNetworkPPD.rawhlp deleted file mode 100644 index 77c3217898..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/InstallNetworkPPD.rawhlp +++ /dev/null @@ -1,187 +0,0 @@ -<TITLE> Dialog: New Network Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=InstallNetwork --> - -<CONTENT> - -<p> - -Use the New Network Printer dialog to install a network printer, -thus making the printer available for printing from the network. - -<p> - -<b> Printer Name:</b> - Specifies a unique name for the printer. The - printer name must be a text string composed of - uppercase or lowercase alphabetical characters - (a-z, A-Z), digits (0-9), hyphens, or - underscores. A printer name can be a maximum of - 14 characters long. -<p> - -<b> Printer Server:</b> This is the computer you have selected to act -as the server for print actions. You must be logged on to this -computer and be running Oracle Solaris Print Manager on it. Oracle -Solaris Print Manager sets up this system with the appropriate software to manage -local and remote printers. - -<p> -<b> Description:</b> - [Optional] Describes the printer, including the printer type and - location, possibly, or provides other information about the - printer. - -<p> - -<b> Printer Make:</b> - Specifies the printer make, or manufacturer. This - information is on the printer and/or in the documentation - that is delivered with the printer. -<p> - -<b> Printer Model:</b> - Specifies the printer model. This information - is found on the printer and/or in the documentation that is - delivered with the printer. - -<p> - -<b> Printer Driver:</b> - Specifies the printer driver to use with this printer. The label - name followed in parentheses by one of the following letters -representing the repository in which the printer driver information resides: -U (user supplied printer information), A (administrator supplied printer -information), V (vendor supplied printer information), or S (system supplied -printer information), precedes the name of the Printer Driver. -<p> - - -<b> Fault Notification:</b> - Specifies how the superuser will be notified in - case of a printer error. - -<p> -<b> Destination:</b> -<br> -For <b>BSD</b> Protocol, the network name of the printer followed by a colon -and the printer-vendor-supplied queue name. -<br> -For <b>TCP</b> Protocol, the network name of the printer followed by a colon -and the tcp port number to connect to. -<br> -For <b>URI</b> Protocol, a printer URI to be used in connecting to the remote -printer. For example: "smb://user@printer-host/printer-name". -<p> - -<b> Protocol:</b> -The internet protocol for file transfer; choices are BSD, TCP, or URI. -<p> - -<b> Options: Default Printer:</b> If checked, this printer is -designated as the default printer for printing jobs sent to this -server. If another printer had been designated as the default printer -for the network, this printer will replace it as the default. If you -are using a naming service, this printer will be the default printer -for the naming service, also. - -<p> Note that this is the last place the print subsystem looks to -determine where a particular print job will be printed; the -destination option of the lp command is the first place looked, and -other environment variables are checked before this one. See the man -page for printers.conf(4) for a full explanation of the search order. - -<p> - -<b> Options: Banner:</b> Specifies whether a banner -page will be printed between jobs. -<br> -<br> -"Aways Print Banner" stipulates that a banner will always be printed -and may not be turned off by the user. -<br> -"User Selectable - Default=on" stipulates that a banner will be printed -unless the user selects -to turn the banner off. -<br> -"Never Print Banner" stipulates that a banner will never be printed -and may not be turned on by the user. - -<p> - -<p> - -<b> User Access List:</b> -Specifies the print clients that can - print to this printer. By default, all print - clients have access to this printer, as designated by the word -"all" in the list. -<p> - -To add a user to the list, type a user name in the blank text field -below the list and click Add. Note that this user name replaces "all" -or "none" if either "all" or "none" is in the user access list. If -"all" or "none" is added as a user, "all" or "none" will replace the -names in the list. - -<p> - -To delete a user from the list, select the user in the list and click -Delete. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> - -</CONTENT> - -<KEYWORDS> - -install "network printer" "printer name" server description port -"printer make" "printer model" "printer driver" fault "fault notification" "default -printer" banner new dialog: network printer - -</KEYWORDS> - -<p> - -<SEEALSO> -ToInstallNetwork -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/LDAPAuthentication.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/LDAPAuthentication.rawhlp deleted file mode 100644 index 2e6070dc66..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/LDAPAuthentication.rawhlp +++ /dev/null @@ -1,132 +0,0 @@ -<TITLE> LDAP Authentication</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=LDAPAuthentication --> - -<CONTENT> - -<p> - -If you are using the LDAP naming service, you will need the distinguished -name and password for a user who has update privileges to make any changes. -Before making changes to the LDAP directory the user should be fully aware of -the items in the <b>notes</b> below. -The LDAP Authentication dialog is displayed when you select LDAP as the -naming service. - -<p> - -1. Check the LDAP server name for correctness. You may select a -different server name if appropriate. - -<p> - -2. Check the Distinguished Name (DN) for correctness. You may enter a -different distinguished name of another user if appropriate. This may be the DN -of any directory user who has permissions (directory update privileges) to -update printer entries in the LDAP directory for the current ldapclient (1M) -naming service (NS) domain. - -<p> - -3. Enter the password for the user's Distinguished Name. - -<p> - -4. Click OK. - -<p> - -The entries you have made will be validated against the LDAP directory and then -saved, the LDAP Authentication dialog will be dismissed. - -<p> - -Click Cancel if you don't know the password for the Distinguished Name. - -<p> - -<b>Note:</b> Keep the following in mind if you are using Oracle Solaris Print -Manager to update printer information in the LDAP naming service: - -<p> - -If the LDAP server is the Netscape Directory Server (NSDS) then -the default distinguished name is "cn=Directory Manager". -If the LDAP server is Sun Directory Server then an example -of the distinguished name is "cn=admin, dc=XYZ, dc=COM". - -The Oracle Solaris Print Manager uses ldapclient(1M) to determine -the default LDAP server name. If there is more than one -server specified then the first one will be used. - -<p> - -The Print Manager always displays printer entries from the current -ldapclient (1M) server. If this is not the domain Master LDAP server then -the list of printers displayed may <b>not</b> be the current list of printers, -this is because the ldapclient replica server may not have been updated by the -master server and so be out of sync with the master. Replica servers can have -various update replication agreements, for example; updated immediately there -is a change on the master, or updated once a day from the master. - -<p> - -If the selected LDAP server is a replica LDAP server, any <b>updates</b> will be -referred to the master server and done there. This again means the printer list -could be out of sync with the master. For example, a deleted printer may still -appear in the displayed printer list until the replica is updated from -the master. - -<p> - -Users can use the ldap command line utilities (ldapadd (1) & ldapmodify (1)) -to update printer entries in the directory, but this is not recommended. If -these utilities are used then the user <b>must ensure</b> that the printer-name -attribute value is unique within the ou=printers container. If it is not unique -the result of modifies done by the print manager (or lpset (1M)) may not be -predictable. - -<p> - -</CONTENT> - -<p> - -<KEYWORDS> - -LDAP ldap "LDAP server" authentication login password naming "naming -service" files "replica server" replica replication referral ldapclient -"distinguished name" DN - -</KEYWORDS> - -<p> - -<SEEALSO> -NameService -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/LoginFailed.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/LoginFailed.rawhlp deleted file mode 100644 index 8844f2323b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/LoginFailed.rawhlp +++ /dev/null @@ -1,59 +0,0 @@ -<TITLE> If Login Fails</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2009 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. ---> -<!-- Tag=LoginFailed --> - -<CONTENT> - -<p> - -If the NIS naming service is being used, you will need to know the -password for the naming service master. If LDAP is being used then -a fully distinguished name with update privilege and password will -be required. Note that default values may need to be overridden. -See the man page for lpadmin(1M) and the help articles, "About -Naming Services" and "NIS Authentication," for further information. - -<p> - -</CONTENT> - -<p> - -<KEYWORDS> -"login failed" login fail failure fails -</KEYWORDS> - -<p> - -<SEEALSO> -ToStart -ToShowCommand -NISAuthentication -NameService -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/MainWindow.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/MainWindow.rawhlp deleted file mode 100644 index 8a7f535d7a..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/MainWindow.rawhlp +++ /dev/null @@ -1,116 +0,0 @@ -<TITLE> Oracle Solaris Print Manager Main Window </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. ---> -<!-- Tag=MainWindow --> - -<CONTENT> - -<p> - -The main window is the starting point for any Oracle Solaris Print Manager -activities. - -<p> -<b> Print Manager Menu: </b> Select Naming Service, Show -Command-Line Console, Confirm All Actions, Exit - -<p> -<b> Printer Menu: </b> Add Access to Printer, New Attached -Printer, New Network Printer, Modify Printer Properties, -Delete Printer - -<p> -<b> Tools Menu: </b> Find Printer - -<p> -<b> Help Menu: </b> Overview, On Help, About Print Manager -<p> - -<b> List of Printers: </b> This is the list of printers installed on -the computer on which you are running Oracle Solaris Print Manager, or, if a -naming service is being used, all printers in the naming service. - -<p> -There are three columns in the list: -<p> - -<b> Printer Name:</b> The name of the printer as specified during printer -installation. -<p> - -<b> Printer Server:</b> The name of the printer server for the printer -specified in the Printer Name column. -<p> - -<b> Description:</b> A description of the printer as specified during -printer installation (New Attached Printer or New Network -Printer) or modification (Modify Printer Properties). The -description might include the location of the printer and its printer -type. - -<p> - -The footer panel at the bottom of the window has two or three entries: - -<p> - -<b> Default Printer: </b> If no naming service is being used, the -default printer for the computer on which you are running Oracle Solaris -Print Manager. If a naming service is being used, the default printer -for the naming service. - -<p> - -<b> Naming Service: </b> The naming service -- NIS or LDAP -- -that is being used for printing. This is not displayed if no naming -service is being used. - -<p> - -<b> Domain or Host: </b> The network domain you are working in or the -current host (if no naming service is being used). If you are -using a naming service, the list of printers includes all printers in -this domain. - -<p> - -</CONTENT> - -<KEYWORDS> -"Print Manager menu" "Printer menu" "Tools menu" "Help menu" "list -of printers" printers "printer name" "printer server" description -"default printer" "naming service" domain Oracle solaris print manager main -window -</KEYWORDS> - -<p> - -<SEEALSO> -Overview -ToAddAccess -ToInstallLocal -ToInstallNetwork -ToModify -ToDelete -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/Modify.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/Modify.rawhlp deleted file mode 100644 index 019f379c43..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/Modify.rawhlp +++ /dev/null @@ -1,167 +0,0 @@ -<TITLE> Dialog: Modify Printer Properties </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=Modify --> - -<CONTENT> - -<p> - -Use the Modify Printer Properties dialog to modify an installed -printer. Note that you can modify the Description field only if this -is not an attached printer. You can also check or uncheck the Default -Printer box. - -<p> - -<b> Printer Name:</b> Cannot be modified. - -<p> - -<b> Printer Server:</b> Cannot be modified. -This is the computer you have selected to act -as the server for print actions. You must be logged on to this -computer and be running Oracle Solaris Print Manager on it. - -<p> - -<b> Description:</b> - [Optional] Describes the printer, including the printer type and - location, possibly, or provides other information about the - printer. - -<p> - -<b> Printer Port:</b> Cannot be modified. -Specifies the hardware port, such as /dev/term/a, that the printer is -connected to. - -<p> - -<b> Printer Type:</b> - Specifies the generic name for a type of - printer. Supported printer types correspond to - items listed in the /usr/share/lib/terminfo - directories. Examples are PostScript, Daisy, and Diablo. - -<p> - -<b> File Contents:</b> - Specifies the format of files that can be - printed without any special filtering by the - print software. PostScript is the default and is - probably correct most of the time. -<p> - -<b> Fault Notification:</b> - Specifies how the superuser will be notified in - case of a printer error. - -<p> - -<b> Options: Default Printer:</b> If checked, designates this printer -as the default printer for printing jobs from the computer on which -you are running Oracle Solaris Print Manager. If you are using a naming -service, this printer will be the default printer for the naming -service, also. - -<p> - -Note that this is the last place the print subsystem looks to -determine where a particular print job will be printed; the -destination option of the lp command is the first place looked, and -other environment variables are checked before this one. See the man -page for printers.conf(4) for a full explanation of the search order. - -<p> - -<b> Options: Banner:</b> Specifies whether a banner -page will be printed between jobs. -<br> -<br> -"Aways Print Banner" stipulates that a banner will always be printed -and may not be turned off by the user. -<br> -"User Selectable - Default=on" stipulates that a banner will be printed -unless the user selects -to turn the banner off. -<br> -"Never Print Banner" stipulates that a banner will never be printed -and may not be turned on by the user. - -<p> - -<b> User Access List:</b> -Specifies the print clients that can - print to this printer. By default, all print - clients have access to this printer, as designated by the word -"all" in the list. - -<p> - -If you want to restrict its use to individual users, enter a user name -in the text field below the list and click Add. Other legal constructs -are system-name!login-ID (user "login-ID" on system "system-name"), -system-name!all (all users on system "system-name"), and all!login-ID -(user "login-ID" on all systems). Use the lpadmin(1M) command to deny -access to users. - -<p> - -To delete a user from the list, select the user in the list and click -Delete. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> -</CONTENT> - -<KEYWORDS> modify properties "printer properties" "attached printer" -"printer name" server description port "printer type" "file contents" -fault "fault notification" "default printer" banner "attached printer" -new nobanner dialog: printer - -</KEYWORDS> - -<p> - -<SEEALSO> -ToModify -ModifyFailed -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ModifyFailed.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ModifyFailed.rawhlp deleted file mode 100644 index 97a59c6a46..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ModifyFailed.rawhlp +++ /dev/null @@ -1,62 +0,0 @@ -<TITLE> If Modify Printer Fails</TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=ModifyFailed --> - -<CONTENT> - -<p> - -An attempt to modify printer properties failed. It is possible that -someone has deleted the printer before this modify operation completed. - -<p> - -Display the Command-Line Console to help pinpoint where the error -may have occurred. Choose Show Command-Line Console from the Print -Manager menu to display the Command-Line Console. See the man page for -lpadmin(1M) for further information. - -</CONTENT> - -<p> - -<KEYWORDS> -modify "modify printer" fail failure printer fails -</KEYWORDS> - -<p> - -<SEEALSO> -ToModify -Modify -ToShowCommand -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ModifyPPD.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ModifyPPD.rawhlp deleted file mode 100644 index 6399b8ac94..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ModifyPPD.rawhlp +++ /dev/null @@ -1,176 +0,0 @@ -<TITLE> Dialog: Modify Printer Properties </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ModifyPPD --> - -<CONTENT> - -<p> - -Use the Modify Printer Properties dialog to modify an installed -printer. Note that you can modify the Description field only if this -is not an attached printer. You can also check or uncheck the Default -Printer box. - -<p> - -<b> Printer Name:</b> Cannot be modified. - -<p> - -<b> Printer Server:</b> Cannot be modified. -This is the computer you have selected to act -as the server for print actions. You must be logged on to this -computer and be running Oracle Solaris Print Manager on it. - -<p> - -<b> Description:</b> - [Optional] Describes the printer, including the printer type and - location, possibly, or provides other information about the - printer. - -<p> - -<b> Printer Port:</b> Cannot be modified. -Specifies the hardware port, such as /dev/term/a, that the printer is -connected to. - -<p> - -<b> Printer Make:</b> - Specifies the printer make, or manufacturer. This - information is on the printer and/or in the documentation - that is delivered with the printer. - -<p> - -<b> Printer Model:</b> - Specifies the printer model. This information - is found on the printer and/or in the documentation that is - delivered with the printer. -<p> - -<b> Printer Driver:</b> - Specifies the printer driver to use with this printer. The label - name followed in parentheses by one of the following letters -representing the repository in which the printer driver information resides: -U (user supplied printer information), A (administrator supplied printer -information), V (vendor supplied printer information), or S (system supplied -printer information), precedes the name of the Printer Driver. -<p> - - -<b> Fault Notification:</b> - Specifies how the superuser will be notified in - case of a printer error. - -<p> - -<b> Options: Default Printer:</b> If checked, designates this printer -as the default printer for printing jobs from the computer on which -you are running Oracle Solaris Print Manager. If you are using a naming -service, this printer will be the default printer for the naming -service, also. - -<p> - -Note that this is the last place the print subsystem looks to -determine where a particular print job will be printed; the -destination option of the lp command is the first place looked, and -other environment variables are checked before this one. See the man -page for printers.conf(4) for a full explanation of the search order. - -<p> - -<b> Options: Banner:</b> Specifies whether a banner -page will be printed between jobs. -<br> -<br> -"Aways Print Banner" stipulates that a banner will always be printed -and may not be turned off by the user. -<br> -"User Selectable - Default=on" stipulates that a banner will be printed -unless the user selects -to turn the banner off. -<br> -"Never Print Banner" stipulates that a banner will never be printed -and may not be turned on by the user. - -<p> - -<b> User Access List:</b> -Specifies the print clients that can - print to this printer. By default, all print - clients have access to this printer, as designated by the word -"all" in the list. - -<p> - -If you want to restrict its use to individual users, enter a user name -in the text field below the list and click Add. Other legal constructs -are system-name!login-ID (user "login-ID" on system "system-name"), -system-name!all (all users on system "system-name"), and all!login-ID -(user "login-ID" on all systems). Use the lpadmin(1M) command to deny -access to users. - -<p> - -To delete a user from the list, select the user in the list and click -Delete. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> -</CONTENT> - -<KEYWORDS> modify properties "printer properties" "attached printer" -"printer name" server description port "printer make" "printer model" -"printer driver" fault "fault notification" "default printer" banner -"attached printer" -new nobanner dialog: printer - -</KEYWORDS> - -<p> - -<SEEALSO> -ToModify -ModifyFailed -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/NISAuthentication.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/NISAuthentication.rawhlp deleted file mode 100644 index 6294176d9b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/NISAuthentication.rawhlp +++ /dev/null @@ -1,97 +0,0 @@ -<TITLE> NIS Authentication</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=NISAuthentication --> - -<CONTENT> - -<p> - -If you are using the NIS naming service, you will need the root -password for the NIS master computer to make any changes. The NIS -Authentication dialog is displayed when you select NIS as the -naming service. - -<p> - -1. Enter the password for the NIS master. - -<p> - -2. Click OK. - -<p> - -The entries you have made will be saved and the NIS Authentication -dialog will be dismissed. - -<p> - -Click Cancel if you don't know the password for the NIS master. - -<p> - -<b>Note:</b> Keep the following in mind if you are using Oracle Solaris Print -Manager to update printer information in the NIS name service: - -<p> - -- If your network is set up with NIS master and slave servers, -the NIS slaves may not see the updated printer information -until the NIS slaves are updated. See ypmake(1M) for more -information. - -<p> - -- If your NIS servers are running Oracle Solaris 2.5 and compatible -versions, you must have explicit permissions on the NIS master -server to update the maps. This means an entry for your system -name must reside in root's .rhosts file on the NIS master server. - -<p> - -- If you have modified the yp makefile to use something other -than /etc/printers.conf as the source for the NIS map, -printers.conf.byname, do not use Oracle Solaris Print Manager to modify NIS. - -</CONTENT> - -<p> - -<KEYWORDS> - -NIS "NIS master" master authentication login password naming "naming -service" files .rhosts - -</KEYWORDS> - -<p> - -<SEEALSO> -NameService -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/NameService.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/NameService.rawhlp deleted file mode 100644 index 885356086f..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/NameService.rawhlp +++ /dev/null @@ -1,155 +0,0 @@ -<TITLE> About Naming Services </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. ---> -<!-- Tag=NameService --> - -<CONTENT> - -<p> - -You can select "files" or a naming service (NIS or LDAP) when you -start up Oracle Solaris Print Manager or when you choose Select Naming -Service from the Print Manager menu. See the descriptions of each -of the choices below. - -<p> - -Once you select a naming service, Print Manager will retrieve and update -printer information in the database for the specified naming service -when you add, modify, or delete a printer. Note that in addition to -the naming service map, when updating attached or network printers -the file /etc/printers.conf is also updated when a naming service -is being used. - -<p> - -When you make a remote printer accessible by choosing Add Access to -Printer from the Printer menu, either the naming service map is -updated or /etc/printers.conf is updated (if "files" is selected and -no naming service is being used). - -<p> - -<b>files</b>: Retrieve or update printer information from -the file /etc/printers.conf. - -<p> - -<b>NIS</b>: Use the printers.conf.byname map stored in the Network -Information Service for retrieving or updating printer information. -See the ypserv(1M) man page for more information. - -<p> - -<b>Note: </b>When a site is set up with a NIS master and slaves, if the -host binds to a slave, a user may not see NIS updates made through -Print Manager until the slave computers are updated. See the ypmake(1M) -man page for more information. - -<p> - -<b>LDAP</b>: Use the printers map stored in the LDAP -naming service for retrieving or updating printer information. -See the ldap(1) man page for more information. - -<p> - -To used the LDAP naming service the host computer must be configured as a -LDAP client, see ldapclient(1M). - -<p> - -<b>Note:</b>If the host binds to a replica LDAP server, a user may not see -updates made through Print Manager until the replica is updated from the master -LDAP server. - -<p> - -The following privileges are needed for each naming service: - -<p> - -<b>For files:</b> - -<p> - -The tool must be started as root. - -<p> - -<b>For NIS:</b> - -<p> - -1) The tool must be started as root. - -<p> - -2) The password for the NIS master will be required when you select -this naming service. - -<p> - -3) For NIS servers running pre-2.6 Oracle Solaris, you need to set up an -rhosts entry on the NIS server allowing root on the print server root -access on the NIS server. You must have explicit permissions on the -NIS master server to update the maps. This means an entry for your -host name must reside in root's .rhosts file on the NIS master server. -See the hosts.equiv(4) man page for more information. - -<p> - -<b>For LDAP:</b> - -<p> - -1) The tool must be started as root. - -<p> - -2) A fully distinguished name (DN) with update privilege and password will - be required when you select this naming service. - -<p> - -</CONTENT> - -<p> - -<KEYWORDS> - -"name service" "naming service" name naming nis none ldap -keylogin printers.conf service files -hosts.equiv nisgrpadm about services - -</KEYWORDS> - -<p> - -<SEEALSO> -ToStart -ToSelectName -Overview -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/Overview.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/Overview.rawhlp deleted file mode 100644 index 361c3580e5..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/Overview.rawhlp +++ /dev/null @@ -1,122 +0,0 @@ -<TITLE> Overview </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=Overview --> - -<CONTENT> - -<p> - -Use Oracle Solaris Print Manager to select a naming service, to install attached -or network printers, and to add, modify, or remove access to installed -printers. Five windows or dialogs and 11 tasks -- listed below -- are described -in the help volume. To view one of the help articles, select it -in the See also pulldown menu and click the Show button. - -<p> - -If you need more information about printing, see the "Oracle Solaris Print -Manager Administration Guide" AnswerBook or the "Setting Up Printers" -chapter in the Oracle Solaris System Administrator AnswerBook. - -<p> - -<b> Windows and Dialogs </b> -<p> -Main Window -<br> -Add Access to Printer -<br> -New Attached Printer -<br> -New Network Printer -<br> -Modify Printer Properties - -<p> -<b>Tasks</b> -<p> -To Start Oracle Solaris Print Manager -<br> -To Add Access to an Installed Printer -<br> -To Install an Attached Printer -<br> -To Install a Network Printer -<br> -To Modify Printer Properties -<br> -To Delete a Printer -<br> -To Select a Naming Service -<br> -To Exit Oracle Solaris Print Manager -<br> -To Find a Printer -<br> -To Show the Command-Line Console -<br> -To Confirm All Actions -<p> - -<b>More About Printing and Oracle Solaris Print Manager </b> - -<p> - -If you need more information about printing or about Oracle Solaris Print -Manager, including a description of mouseless navigation, see the -"Oracle Solaris Print Manager Administration Guide" AnswerBook or the -"Setting Up Printers" chapter in the Oracle Solaris System Administrator -AnswerBook. - -<p> - -</CONTENT> - -<KEYWORDS> -overview contents task dialog -</KEYWORDS> - -<p> - -<SEEALSO> -MainWindow -AddAccess -InstallLocal -InstallNetwork -Modify -ToAddAccess -ToStart -ToInstallLocal -ToInstallNetwork -ToModify -ToDelete -ToSelectName -ToExit -ToFindPrinter -ToShowCommand -ToConfirmActions -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrintManagerSettings.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrintManagerSettings.rawhlp deleted file mode 100644 index de175c0b7d..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrintManagerSettings.rawhlp +++ /dev/null @@ -1,111 +0,0 @@ -<TITLE> Print Manager Settings </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=Overview --> - -<CONTENT> - -<p> - -The Oracle Solaris Print Manager has tool-wide settings that may be selected. -Each of these choices applies to all further tasks utilized within the -Oracle Solaris Print Manager. For example, once Show Command-Line Console has been -selected, or checked, the Console will be visible for all tasks until -this selection is turned off, or unchecked. - - -<p> - -<b> Show Command-Line Console: </b> -The Command-Line Console displays the command-line version of add, modify, -delete actions. Errors and warnings may also be displayed after the -command. - -<p> -The default is off. - -<p> - -<b> Confirm All Actions: </b> -When Confirm All Actions is selected, all subsequent Oracle Solaris Print -Manager actions will require confirmation before being performed. - -<p> -The default is off. - -<p> -<b> Use PPD files: </b> -When configuring local printers, PPD files may be used to describe the -printer. If selected, the New Attached Printer and New Network Printer -screens offer the selection of printer Make, Model, and Printer Driver -from matching PPD files. Duplicate entries may be displayed from -PPD files in different labels within different PPD file repositories -that represent suppliers of the PPD files. Thus, the label name -associated with the PPD file, and one of the following letters, -within parentheses, representing the repository in which the printer -driver information resides: U (user supplied printer information), -A (administrator supplied printer information), V (vendor supplied -printer information), or S (system supplied printer information), -precedes the name of the Printer Driver. - -<p> -The default is on. - -<p> -<b> Use localhost for Print Server Name: </b> - -The print server name utilized by the Oracle Solaris Print System may be -either the hostname or "localhost". This applies to the tasks for adding -new local printers in the "files" Name Service: New Attached Printer -and New Network Printer. The use of "localhost" is recommended. - -<p> -The default is on. -<p> - -Documentation about Printing Services is found in the System Administration -Guide: Advanced Administration. - -</CONTENT> - -<KEYWORDS> -confirm action all actions "command-line" log console show "local printer" -"printer model" "printer driver" "printer make" localhost hostname -</KEYWORDS> - -<p> - -<SEEALSO> -Overview -MainWindow -ShowCommandConsole -ToConfirmActions -ToShowCommand -InstallLocalPPD -InstallNetworkPPD -ToExit -HelpOnHelp - -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrinterPort.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrinterPort.rawhlp deleted file mode 100644 index 23d11c054f..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrinterPort.rawhlp +++ /dev/null @@ -1,67 +0,0 @@ -<TITLE> Specify Printer Port </TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=PrinterPort --> - -<CONTENT> - -<p> - -The printer port is the device name (typically, /dev/term/a, -/dev/term/b, or /dev/bpp0) corresponding to the port to which a -locally attached printer is physically connected. You usually connect -printer cables to a serial port (/dev/term/a or /dev/term/b, for -example) but in some cases you can use a parallel port (/dev/bpp0, for -example). See the printer vendor's documentation and your system's -installation documentation for information about switch settings and -cabling requirements. - -<p> - -Note that the device name must exist and have write permissions -set. - -<p> - -</CONTENT> - -<KEYWORDS> -port "printer port" other specify printer -</KEYWORDS> - -<p> - -<SEEALSO> -InstallLocal -ToInstallLocal -Overview -MainWindow -HelpOnHelp -</SEEALSO> - - - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrinterType.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrinterType.rawhlp deleted file mode 100644 index 5ef9a49fce..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/PrinterType.rawhlp +++ /dev/null @@ -1,64 +0,0 @@ -<TITLE> Specify Printer Type </TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=PrinterType --> - -<CONTENT> - -<p> - -When you configure a printer, you must identify the manufacturer -and model of the printer in a way that the LP print service -understands the printer type. Examples are PostScript, Daisy, and Diablo. - -<p> - -If you have a PostScript printer, for example, select PostScript as -the Printer Type. To install a printer type that is not listed select -Other. The printer type you enter must correspond to an entry in the -/usr/share/lib/terminfo directories. See the terminfo(4) man page for -more information. - -<p> - -</CONTENT> - -<KEYWORDS> -"printer type" type specify printer -</KEYWORDS> - -<p> - -<SEEALSO> -InstallLocal -InstallNetwork -ToInstallLocal -ToInstallNetwork -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/RemoteServer.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/RemoteServer.rawhlp deleted file mode 100644 index 2188adb1c1..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/RemoteServer.rawhlp +++ /dev/null @@ -1,53 +0,0 @@ -<TITLE> Specify Remote Server </TITLE> -<!-- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright 2001 Sun Microsystems, Inc. All rights reserved. --- Use is subject to license terms. --- --- ident "%Z%%M% %I% %E% SMI" ---> -<!-- Tag=RemoteServer --> - -<CONTENT> - -<p> - -A printer server must be specified; the printer server is the computer -on which the software for the remote printer is installed. - -<p> - -</CONTENT> - -<KEYWORDS> -remote "remote printer" server "printer server" fail failure specify -</KEYWORDS> - -<p> - -<SEEALSO> -AddAccess -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ShowCommandConsole.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ShowCommandConsole.rawhlp deleted file mode 100644 index 26b00dc463..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ShowCommandConsole.rawhlp +++ /dev/null @@ -1,84 +0,0 @@ -<TITLE> Command-Line Console</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ShowCommandConsole --> - -<CONTENT> - -<p> - -The Command-Line Console displays the command-line version of add, -modify, and delete actions. Errors and warnings may also be -displayed after the command. - -<p> - -For example, if you choose Add Access to Printer from the Print -Manager menu and enter Printer Name = MyPrinter, Printer Server = -PrintServer2, Description = Local Printer, the Command-line Console -will display: - -<p> - -Add Access to printer -<br> -% /usr/sbin/lpadmin -p MyPrinter -s PrintServer2 -D "Local Printer" - -<p> - -The Command-line Console is displayed if the Show Command-Line Console box -is checked in the Print Manager menu. - -<p> - -<b>Note: </b>When updating the NIS naming service, there are some -cases where there is no command line equivalent for what Oracle Solaris Print -Manager is doing. In these cases what gets reported to the -Command-Line console is: "rsh [nis_master] ..." or -"rexec([nis_master]) ..." - -<p> - -<b>Note: </b>When updating the LDAP naming service, the Oracle Solaris Print -Manager uses native (or compiled) code to process updates. This -is done to enhance security related to the LDAP password. The command-line -used to update the LDAP database is not displayed for security reasons, but -the log will include the entry "ldap ..." to indicate that the LDAP database -has been updated. - -<p> - -</CONTENT> - -<KEYWORDS> -"command-line" log command console show -</KEYWORDS> - -<p> - -<SEEALSO> -Overview -MainWindow -ToShowCommand -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToAddAccess.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToAddAccess.rawhlp deleted file mode 100644 index d1c994ae88..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToAddAccess.rawhlp +++ /dev/null @@ -1,141 +0,0 @@ -<TITLE>To Add Access to an Installed Printer</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToAddAccess --> - -<CONTENT> - -<p> - -Do the following to make an installed printer accessible to print -client computers. See the printers.conf(4) man page for more -information about print client commands. - -<p> - -<b>Note:</b> If you are using a naming service, use this procedure to -add access to a private printer (one that is not listed in the naming -service) or to make the printer usable even if the naming service -server is down. This adds access for all users in the naming service -domain; see the man page for domainname(1M) for more information about -domains. - -<p> - -If a naming service is not being used for printing, use this procedure -to add access to a remote printer. - -<p> - -1. Choose Add Access to Printer from the Printer menu. - -<p> - - The Add Access To Printer dialog is displayed. - -<p> - -2. Enter a printer name, printer server name, and description (optional). - -<p> - -Note that Oracle Solaris Print Manager does not check for the validity of -Printer Name or Printer Server. - -<p> - -3. Click Default Printer if you want this printer to be the default -printer. - -<p> - -If a naming service is being used, this printer will be designated as -the default printer for all users in the domain. - -<p> - -If no naming service is being used, this printer will be designated as -the default printer for the computer on which you are running Oracle Solaris -Print Manager. - -<p> - -Note that this is the last place the print commands will look to -determine the printer for a specific print command; see the -man page for printers.conf(4) for more information about resolving -printer conflicts. - -<p> - -4. Click OK or Apply to add access for the specified printer. - -<p> - -<b> Note:</b> If you are using the NIS naming service, you have to know the -root password for the NIS master. If you are using the LDAP naming service, -you must know a fully distinguished name which has update privilege and -the corresponding password. Default values may need to be overridden. You -will be prompted for the password when you click Apply or OK. Enter the -password and click OK. - -<p> - The list of printers displayed in the Oracle Solaris Print Manager main window - is updated to include the new printer. -<p> - The Add Access dialog will remain displayed if you click Apply, -allowing you to add access to additional printers. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> - -</CONTENT> - -<KEYWORDS> -access "add access" description "default printer" "naming service" -"printer name" "printer server" add installed printer -</KEYWORDS> - -<p> - -<SEEALSO> -AddAccess -ToModify -ToDelete -MainWindow -HelpOnHelp -</SEEALSO> - - - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToConfirmActions.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToConfirmActions.rawhlp deleted file mode 100644 index af9d31a9ac..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToConfirmActions.rawhlp +++ /dev/null @@ -1,66 +0,0 @@ -<TITLE> To Confirm All Actions </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToConfirmActions --> - -<CONTENT> - -<p> - -Do the following to require that all Oracle Solaris Print Manager actions be -confirmed before being executed, or to turn off this option. - -<p> - -1. Choose Confirm All Actions from the Print Manager menu. - -<p> - -If the Confirm All Actions box was not checked, it will be checked -and all subsequent Oracle Solaris Print Manager actions will require -confirmation before being performed. - -<p> - -If the Confirm All Actions box was checked, it will no longer be checked -and subsequent Oracle Solaris Print Manager actions will NOT require -confirmation before being performed. Note that some actions, such as -Delete Printer, require confirmation regardless of the setting of the -Confirm All Actions box. - -<p> - -</CONTENT> - -<KEYWORDS> -confirm action all actions -</KEYWORDS> - -<p> - -<SEEALSO> -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToDelete.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToDelete.rawhlp deleted file mode 100644 index 0842d3046b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToDelete.rawhlp +++ /dev/null @@ -1,81 +0,0 @@ -<TITLE> To Delete a Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToDelete --> - -<CONTENT> - -<p> - -Do the following to delete a printer from the printer list. - -<p> 1. Select the printer in the list of printers in the Oracle Solaris -Print Manager main window. - -<p> - -2. Choose Delete Printer from the Printer menu. - -<p> - -A dialog is displayed, -asking if you really want to delete the selected printer. - -<p> <b>Note:</b> If the printer is a local printer (one installed on -the current server), the printer will be uninstalled; if a naming -service has been selected, the entry for this printer will also be -removed from the naming service. - -<p> -3. Click OK to delete the printer. -<p> - A window is displayed asking you to confirm the - deletion. -<p> -4. Click Delete. -<p> -The selected printer is deleted from the Oracle Solaris Print Manager main -window. - -<p> - -</CONTENT> - -<KEYWORDS> -delete uninstall "local printer" "network printer" "attached printer" -printer -</KEYWORDS> - -<p> - -<SEEALSO> -ToAddAccess -AddAccess -MainWindow -Overview -HelpOnHelp -</SEEALSO> - - - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToExit.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToExit.rawhlp deleted file mode 100644 index 2f8ed987fc..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToExit.rawhlp +++ /dev/null @@ -1,53 +0,0 @@ -<TITLE> To Exit Oracle Solaris Print Manager </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToExit --> - -<CONTENT> - -<p> - -1. Choose Exit from the Print Manager menu. - -<p> - -The Oracle Solaris Print Manager main window and any other open Print Manager -dialogs are closed. - -<p> - -</CONTENT> - -<KEYWORDS> -exit close Oracle solaris print manager -</KEYWORDS> - -<p> - -<SEEALSO> -ToStart -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToFindPrinter.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToFindPrinter.rawhlp deleted file mode 100644 index 1f8f54b42d..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToFindPrinter.rawhlp +++ /dev/null @@ -1,68 +0,0 @@ -<TITLE> To Find a Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToFindPrinter --> - -<CONTENT> - -<p> - -Do the following to find a printer in the Oracle Solaris Print Manager list -of printers. - -<p> - -1. Choose Find Printer from the Tools menu. - -<p> - -A dialog will be displayed, asking you to enter the name of a printer to find. - -<p> - -2. Type a printer name in the text field and click Find. - -<p> - -If the exact printer name is found in the list, it will be selected; -the list will scroll, if necessary. If the printer is not found, a -message will be displayed, indicating that the named printer was not -found in the current list. - -<p> - -</CONTENT> - -<KEYWORDS> -find "printer name" tool printer -</KEYWORDS> - -<p> - -<SEEALSO> -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToInstallLocal.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToInstallLocal.rawhlp deleted file mode 100644 index ce6cc22764..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToInstallLocal.rawhlp +++ /dev/null @@ -1,176 +0,0 @@ -<TITLE> To Install an Attached Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToInstallLocal --> - -<CONTENT> - -<p> - -Once you have physically connected the printer to the printer server, -do the following to install the printer, which makes the printer -available for printing from the computer on which you are running -Oracle Solaris Print Manager. - -<p> - -<b> Note:</b> The computer on which you are running Oracle Solaris Print -Manager becomes the printer server for the printer being installed. - -<p> - -1. Choose New Attached Printer from the Printer menu. - -<p> - -The New Attached Printer dialog will be displayed. - -<p> - -2. Enter a name in Printer Name. -<p> - -3. [Optional] Enter a description of the printer. - -<p> -This might include the location and the type of printer. - -<p> -4. Select a port from the Printer Port pulldown menu. - -<p> -This is the hardware port where the printer is plugged into the -server. If you choose Other, a dialog will pop up asking you to -specify a port. Enter a port and click OK. - -<p> -5. Select a printer type from the Printer Type pulldown menu. - -<p> - -Scroll the list if necessary. If the printer type is not in the list, -select Other; you will be asked to specify a printer type. Enter a -printer type and click OK. - -<p> -6. Select an item in the File Contents pulldown menu. - -<p> -Choices include PostScript and ASCII; the default is PostScript, which -will work in most cases. - -<p> -7. Select an item in the Fault Notification pulldown menu. - -<p> - -The default is Write to Superuser. - -<p> -8. [Optional] Click Default Printer if you want this printer to be the default -printer for this server. - -<p> - -9. [Optional] Select option to define whether a banner -page is to be printed between jobs. "Always Print Banner" -specifies that a banner will be printed and the user may not specify -otherwise. "User Selectable - Default=on" specifies that the user may -specify to turn off the banner in the print command; if the user does -not specify, the banner will be printed. "Never Print Banner" specifies -that a banner will not be printed and the user may not specify -otherwise. The default action is to always print the banner. - -<p> - -10. Modify the User Access List, if necessary. - -<p> - -The default value is "all," meaning that anyone can use this printer. -If you want to restrict its use to individual users, enter a user name -in the text field below the list and click Add. Other legal constructs -are system-name!login-ID (user "login-ID" on system "system-name"), -system-name!all (all users on system "system-name"), and all!login-ID -(user "login-ID" on all systems). Use the lpadmin(1M) command to deny -access to users. - -<p> - -To remove a name from the list, select it and click Delete. - -<p> - -<b> Note:</b> If you enter "all" or "none" in the text field and click -Add, all individual user names will be deleted from the list and -replaced by "all" or "none." - -<p> -11. Click OK or Apply to install the printer. - -<p> -The window will remain if you click Apply, allowing you to install -additional printers. - -<p> - -<b> Note:</b> If you are using the NIS naming service, you have to know -the root password for the NIS master. If you are using the LDAP naming -service you must know a fully distinguished name which has update -privilege and the corresponding password. Default values may need to be -overridden. You will be prompted for the password when you click Apply or OK. -Enter the password and click OK. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> - -</CONTENT> - -<KEYWORDS> -install "local printer" "printer name" server description port -"printer type" "file contents" fault "fault notification" "default -printer" banner nobanner "attached printer" new attached printer - -</KEYWORDS> - -<p> - -<SEEALSO> -InstallLocal -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToInstallNetwork.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToInstallNetwork.rawhlp deleted file mode 100644 index 60c41b168d..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToInstallNetwork.rawhlp +++ /dev/null @@ -1,181 +0,0 @@ -<TITLE> To Install a Network Printer </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToInstallNetwork --> - -<CONTENT> - -<p> - -Once you have physically connected the printer to the network, -do the following to install the printer, which makes the printer -available for printing from the network. - -<p> - -<b> Note:</b> The computer on which you are running Oracle Solaris Print -Manager becomes the printer server for the printer being installed. - -<p> - -1. Choose New Network Printer from the Printer menu. - -<p> - -The New Attached Printer dialog will be displayed. - -<p> - -2. Enter a name in Printer Name. - -<p> - -3. [Optional] Enter a description of the printer. - -<p> -This might include the location and the type of printer. - -<p> -4. Select a printer type from the Printer Type pulldown menu. - -<p> - -Scroll the list if necessary. If the printer type is not in the list, -select Other; you will be asked to specify a printer type. Enter a -printer type and click OK. - -<p> -5. Select an item in the File Contents pulldown menu. - -<p> -Choices include PostScript and ASCII; the default is PostScript, which -will work in most cases. - -<p> -6. Select an item in the Fault Notification pulldown menu. - -<p> - -The default is Write to Superuser. - -<p> -7a. If the printer uses BSD protocol, enter the network name of the printer -in the Destination field, followed by a colon and the printer-vendor-supplied -queue name. -<p> -7b. If the printer uses TCP protocol, enter the network name of the printer -in the Destination field, followed by a colon and port number to be used in the -tcp connection to the printer. -<p> -7c. If the printer uses a printer URI, enter the the URI for the printer -in the Destination field (for example: -"smb://printer-host/printer-name"). - -<p> -8. Select either BSD, TCP, or URI from the Protocol pulldown menu. - -<p> -9. [Optional] Click Default Printer if you want this printer to be the default -printer for this server. - -<p> - -10. [Optional] Select option to define whether a banner -page is to be printed between jobs. "Always Print Banner" -specifies that a banner will be printed and the user may not specify -otherwise. "User Selectable - Default=on" specifies that the user may -specify to turn off the banner in the print command; if the user does -not specify, the banner will be printed. "Never Print Banner" specifies -that a banner will not be printed and the user may not specify -otherwise. The default action is to always print the banner. - -<p> -11. Modify the User Access List, if necessary. - -<p> - - -The default value is "all," meaning that anyone can use this printer. -If you want to restrict its use to individual users, enter a user name -in the text field below the list and click Add. Other legal constructs -are system-name!login-ID (user "login-ID" on system "system-name"), -system-name!all (all users on system "system-name"), and all!login-ID -(user "login-ID" on all systems). Use the lpadmin(1M) command to deny -access to users. - -<p> - -<b> Note:</b> If you enter "all" or "none" in the text field and click -Add, all individual user names will be deleted from the list and -replaced by "all" or "none." - -<p> -12. Click OK or Apply to install the printer. - -<p> -The window will remain if you click Apply, allowing you to install -additional printers. - -<p> - -<b> Note:</b> If you are using the NIS naming service, you have to know -the root password for the NIS master. If you are using the LDAP naming -service, you must know a fully distinguished name which has update privilege -and the corresponding password. Default values may need to be overridden. -You will be prompted for the password when you click Apply or OK. -Enter the password and click OK. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> - -</CONTENT> - -<KEYWORDS> - -install network "network printer" "printer name" server description -port "printer type" "file contents" fault "fault notification" -"default printer" banner destination protocol new bsd tcp printer - -</KEYWORDS> - -<p> - -<SEEALSO> -InstallNetwork -ToAddAccess -Overview -MainWindow -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToModify.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToModify.rawhlp deleted file mode 100644 index 567520e439..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToModify.rawhlp +++ /dev/null @@ -1,119 +0,0 @@ -<TITLE> To Modify Printer Properties </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToModify --> - -<CONTENT> - -<p> - -Do the following to modify the properties of an installed printer. - -<p> - -1. Double-click the printer in the Oracle Solaris Print Manager main window -<p> - OR -<p> - Select the printer in the Oracle Solaris Print Manager main window and choose - Modify Printer Properties from the Printer menu. -<p> - The Modify Printer Properties dialog is displayed. - -<p> -2. Modify the printer configuration, as needed. -<p> - -If this is an attached printer (one installed on the computer on which -you are running Oracle Solaris Print Manager) you can modify the Description, -Printer Port, Printer Type, File Contents, Fault Notification, -Options, and User Access List. - -<p> - -If this is not an attached printer, only the Description field can be -modified. You can also check or uncheck the Default Printer box. - -<p> -3. Click OK. -<p> - -The changes you made are saved and the Modify Printer Properties -dialog is dismissed. - -<p> - - If you modified the Description field, the new description is -displayed in the Oracle Solaris Print Manager main window. - -<p> - -<b> Note:</b> If you are using the NIS naming service, you have to know -the root password for the NIS master. If you are using the LDAP naming service, -you must know a fully distinguished name which has update privilege and -the corresponding password. Default values may need to be overridden. -You will be prompted for the password when you select the NIS or -LDAP naming service. Enter the password and click OK. - -<p> - -<b> Note:</b> To modify the Printer Name or Printer Server field, -delete the printer and add it with a new printer and/or server name. - -<p> - -<b>OK:</b> Apply changes and dismiss the window. -<br> -<b>Apply:</b> Apply the changes and leave the window displayed. -<br> -<b>Reset:</b> Reset all fields to last Apply -<br> -<b>Cancel:</b> Dismiss the window. -<br> -<b>Help:</b> Display help for the current window or dialog. - -<p> -</CONTENT> - -<KEYWORDS> -modify "Printer menu" "local printer" nis "nis master" "naming service" -ldap LDAP attached "network printer" local network printer properties -</KEYWORDS> - -<p> - -<SEEALSO> -Modify -ModifyFailed -InstallLocal -InstallNetwork -ToInstallLocal -ToInstallNetwork -ToAddAccess -ToDelete -AddAccess -MainWindow -Overview -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToSelectName.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToSelectName.rawhlp deleted file mode 100644 index 80eebff891..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToSelectName.rawhlp +++ /dev/null @@ -1,83 +0,0 @@ -<TITLE> To Select a Naming Service </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToSelectName --> - -<CONTENT> - -<p> - -Do the following to select a naming service for Oracle Solaris Print Manager or -to change from using a naming service to using no naming service. - -<p> - -When you select a naming service you are specifying where Oracle Solaris -Print Manager will retrieve printer information from, and where -changes made in Print Manager will be made. If a naming service is -selected, additions and deletions will be made in the printing -configuration database for the selected naming service. If you choose -"files," the /etc/printers.conf file will be used to determine which -printers are available, and changes will be made there. - -<p> - -1. Choose Select Naming Service from the Print Manager menu. - -<p> - -A dialog is displayed, asking you to choose a naming service. - -<p> - -2. Choose a naming service (or "files," if no naming service is to be -used) and click OK. - -<p> - -The Oracle Solaris Print Manager main window is displayed, listing all the -accessible printers, which includes all printers in the selected -naming service's printer configuration database. - - -<p> - -See the man page for printers.conf(4) for more information. - -</CONTENT> - -<KEYWORDS> -select "name service" "naming service" name naming service -</KEYWORDS> - -<p> - -<SEEALSO> -NameService -ToStart -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToShowCommand.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToShowCommand.rawhlp deleted file mode 100644 index ad5324a322..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToShowCommand.rawhlp +++ /dev/null @@ -1,75 +0,0 @@ -<TITLE> To Show Command-Line Console</TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToShowCommand --> - -<CONTENT> - -<p> - -Do the following to cause the command-line version of add, modify, and -delete actions to be displayed in the Oracle Solaris Print Manager -Command-Line Console -- or to turn off this option if it was -previously turned on. Errors and warnings may also be -displayed after the command. - -<p> - -1. Choose Show Command-Line Console from the Print Manager menu. - -<p> - -If the Show Command-line Console box was not checked when you chose -it, it will be checked and the Show Command-line Console will be -displayed; Oracle Solaris Print Manager actions will be displayed in the -Console. - -<p> - -Note that errors and warnings may also appear in the Console, after -the commands used to complete the action. - -<p> - -If the Show Command-line Console box was checked when you chose it, -it will no longer be checked and the Show Command-line Console will be -closed. - -<p> - -</CONTENT> - -<KEYWORDS> -"command-line" log command show console -</KEYWORDS> - -<p> - -<SEEALSO> -ShowCommandConsole -Overview -MainWindow -HelpOnHelp -</SEEALSO> - diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToStart.rawhlp b/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToStart.rawhlp deleted file mode 100644 index 10b238a49f..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/client/raw-help/ToStart.rawhlp +++ /dev/null @@ -1,81 +0,0 @@ -<TITLE> To Start Oracle Solaris Print Manager </TITLE> -<!-- - 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 - or http://www.opensolaris.org/os/licensing. - 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 - --- Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. --- ---> -<!-- Tag=ToStart --> - -<CONTENT> - -<p> - -If you have installed SUNWppm package, do the following to start -Oracle Solaris Print Manager. Note that you must be root to run Print -Manager; if you attempt to launch it from Solaris Management Console -you will be prompted for the root password. - -<p> - -1. Double-click the Oracle Solaris Print Manager icon in Solaris Management -Console - -<p> - - OR - -<p> - -cd to the directory /usr/sadm/admin/bin and as root type ./printmgr - -<p> - -A dialog is displayed, asking you to choose a naming service. - -<p> - -2. Choose a naming service (or files, if no naming service is to be -used) and click OK. - -<p> - -The Oracle Solaris Print Manager main window is displayed, listing all the -printers accessible from the computer on which you are running Oracle Solaris -Print Manager. - -<p> - -</CONTENT> - -<KEYWORDS> -start startup load "name service" "naming service" SUNWppm "Solaris Management Console" -"the Console" Oracle solaris print manager -</KEYWORDS> - -<p> - -<SEEALSO> -ToSelectName -ToExit -Mainwindow -Overview -HelpOnHelp -</SEEALSO> diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Debug.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Debug.java deleted file mode 100644 index dc0147b093..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Debug.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * Debug class - */ - -package com.sun.admin.pm.server; - -import java.util.*; - -/** - * A simple configurable debug logging class. - * <p> - * - * Calling member classes <b>message()</b>, <b>warning()</b>, - * <b>error()</b>, and <b>fatal()</b> causes a log entry to be - * generated if the current verbosity level is greater than or equal - * to the specified severity. - * <p> - * - * Calling <b>setDebugLevel()</b> sets the verbosity level, which is a - * threshold of severity below which messages will not be logged. The - * verbosity level can be set at any time. - * <p> - * - * For example, setting the verbosity level to <b>Debug.ERROR</b> - * means that only <b>error()</b> and <b>fatal()</b> calls will - * generate log entries, while setting the level to <b>WARNING</b> - * will log <b>warning()</b> calls as well as <b>error()</b> and - * <b>fatal()</b> while ignoring <b>message()</b>. - * <p> - * - * Setting the verbosity level to <b>ALL</b> is equivalent to setting - * it to <b>MESSAGE</b>; all calls are logged. The constant - * <b>NONE</b> suppresses logging of all calls. - * <p> - * - * The verbosity level can be set globally or on a class-by-class - * basis. Use the form of <b>setDebugLevel()</b> which takes an - * argument of type Object to set the level for all instances of the - * specified class. - * <p> - * - * Using the forms of <b>message()</b>, <b>warning()</b>, - * <b>error()</b>, and <b>fatal()</b> which accept an argument of type - * Object will use the verbosity value associated with the specified - * class. If no value has been explicitly set for the class, the - * global default will be used. - * <p> - * - * At present log messages are written only to stdout. - * An enhancement would be to implement an interface to the syslog facility. - */ - - -public class Debug { - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void fatal(String s) { - printIf(s, FATAL); - } - - /** - * Log a high-priority message. - * @param String s The message to be logged. - */ - static public void error(String s) { - printIf(s, ERROR); - } - - /** - * Log a medium-priority message. - * @param String s The message to be logged. - */ - static public void warning(String s) { - printIf(s, WARNING); - } - - /** - * Log a low-priority message. - * @param String s The message to be logged. - */ - static public void message(String s) { - printIf(s, MESSAGE); - } - - - /** - * Log a lowest-priority message. - * @param String s The message to be logged. - */ - static public void info(String s) { - printIf(s, INFO); - } - - - /** - * Log a highest-priority message. - * @param String s The message to be logged. - */ - static public void fatal(Object o, String s) { - printIf(o, s, FATAL); - } - - /** - * Log a high-priority message. - * @param String s The message to be logged. - */ - static public void error(Object o, String s) { - printIf(o, s, ERROR); - } - - /** - * Log a medium-priority message. - * @param String s The message to be logged. - */ - static public void warning(Object o, String s) { - printIf(o, s, WARNING); - } - - /** - * Log a low-priority message. - * @param String s The message to be logged. - */ - static public void message(Object o, String s) { - printIf(o, s, MESSAGE); - } - - /** - * Log a lowest-priority message. - * @param String s The message to be logged. - */ - static public void info(Object o, String s) { - printIf(o, s, INFO); - } - - /** - * Set the verbosity level to the specified severity. - * @param String s The message to be logged. - */ - static public void setDebugLevel(int lvl) { - if (lvl < ALL || lvl > NONE) - return; - - globalDebugLevel = lvl; - } - - /** - * Set the verbosity level to the specified severity. - * @param String s The message to be logged. - */ - static public void setDebugLevel(Object o, int lvl) { - if (lvl < ALL || lvl > NONE) - return; - - classDB.put(o.getClass(), new Integer(lvl)); - - /* - * System.out.println("Debug: class " + o.getClass().getName() + - * " level = " + classDB.get(o.getClass())); - */ - } - - static public void setDebugLevel(String classname, int lvl) { - if (lvl < ALL || lvl > NONE) - return; - - try { - classDB.put(Class.forName(classname), new Integer(lvl)); - } catch (Exception x) { - System.out.println("setDebugLevel: " + x); - } - } - - - private static void printIf(String s, int lvl) { - if (lvl < globalDebugLevel) - return; - debugPrint(s); - } - - private static void printIf(Object o, String s, int lvl) { - if (lvl < getLevelForClass(o)) - return; - debugPrint(s); - } - - - /* - * get debug level for o's class, if already there - * otherwise create an entry for o and set it to the global level - */ - private synchronized static int getLevelForClass(Object o) { - int lvl = globalDebugLevel; - Object g; - if ((g = classDB.get(o.getClass())) != null) - lvl = ((Integer) g).intValue(); - else - classDB.put(o.getClass(), new Integer(lvl)); - - /* - * System.out.println("Debug: getLevelForClass " + - * o.getClass().getName() + - * " = " + lvl); - */ - - return lvl; - } - - // here is where we could hide syslog or file destination... - private static void debugPrint(String s) { - System.out.println(s); // for now - } - - Object theInstance = null; - - public Debug(Object o) { - theInstance = o; - } - - public void SetDebugLevel(int lvl) { - if (lvl < ALL || lvl > NONE) - return; - setDebugLevel(theInstance, lvl); - } - - public void Fatal(String s) { - fatal(theInstance, s); - } - - public void Warning(String s) { - warning(theInstance, s); - } - - public void Error(String s) { - error(theInstance, s); - } - - public void Message(String s) { - message(theInstance, s); - } - - public void Info(String s) { - info(theInstance, s); - } - - /* - * Verbosity level to suppress all messages. - */ - static public final int NONE = 6; - - /* - * Verbosity level to log only highest-priority messages. - */ - static public final int FATAL = 5; - - /* - * Verbosity level to log high- and highest-priority messages. - */ - static public final int ERROR = 4; - - /* - * Verbosity level to log medium-, high-, and highest-priority messages. - */ - static public final int WARNING = 3; - - /* - * Verbosity level to log low-, medium-, high-, and - * highest-priority messages. - */ - static public final int MESSAGE = 2; - - /* - * Verbosity level to log lowest-, low-, medium-, high-, and - * highest-priority messages. - */ - static public final int INFO = 1; - - - /* - * Verbosity level to log all messages. - */ - static public final int ALL = 0; - - private static int globalDebugLevel = FATAL; - private static Hashtable classDB = new Hashtable(); - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterAdd.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterAdd.java deleted file mode 100644 index 287b0a328b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterAdd.java +++ /dev/null @@ -1,552 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -public class DoPrinterAdd { - - public static void main(String[] args) { - // - // Set attributes for testing - // - NameService ns = new NameService(); - - String file_contents[] = new String[1]; - file_contents[0] = "any"; - String user_allow_list[] = new String[1]; - user_allow_list[0] = "allow1"; - String user_deny_list[] = new String[1]; - user_deny_list[0] = "deny1"; - - Printer p = new Printer(ns); - p.setPrinterName("javatest"); - p.setPrinterType("PS"); - p.setPrintServer("zelkova"); - p.setComment("This is a comment"); - p.setDevice("/var/tmp/test"); - p.setNotify("none"); - p.setProtocol("bsd"); - p.setDestination(null); - p.setFileContents(file_contents); - p.setUserAllowList(user_allow_list); - p.setIsDefaultPrinter(false); - p.setBanner("never"); - p.setEnable(true); - p.setAccept(true); - p.setLocale(null); - - try { - add(p, ns); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - System.out.println("Commands:\n" + p.getCmdLog()); - System.out.println("Errors:\n" + p.getErrorLog()); - System.out.println("Warnings:\n" + p.getWarnLog()); - System.exit(0); - } - - // - // Interface to Printer object. - // - public static void add( - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterAdd.add()"); - - String device = p.getDevice(); - if (device == null) { - addRemote(p, ns); - } else { - addLocal(p, ns); - } - return; - } - - // - // Do the work of adding a local printer. - // - private static void addLocal( - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterAdd.addLocal()"); - - int exitvalue = 0; - String err = null; - String cmd = null; - SysCommand syscmd = null; - - // Since it's local set extensions. - // Eventually the gui should do this. - p.setExtensions("Solaris"); - - String printername = p.getPrinterName(); - String printertype = p.getPrinterType(); - String printserver = p.getPrintServer(); - String comment = p.getComment(); - String device = p.getDevice(); - String make = p.getMake(); - String model = p.getModel(); - String ppd = p.getPPD(); - String notify = p.getNotify(); - String protocol = p.getProtocol(); - String destination = p.getDestination(); - String[] file_contents = p.getFileContents(); - String[] user_allow_list = p.getUserAllowList(); - String[] user_deny_list = p.getUserDenyList(); - boolean default_printer = p.getIsDefaultPrinter(); - String banner = p.getBanner(); - boolean enable = p.getEnable(); - boolean accept = p.getAccept(); - - String nameservice = ns.getNameService(); - String ppdfile = null; - - // - // "uri" is a pseudo protocol and means that the device is - // specified in the destination. - // - if ((protocol != null) && (protocol.equals("uri"))) { - device = destination; - destination = null; - protocol = null; - } - - if (ppd != null) { - ppdfile = new String( - DoPrinterUtil.getPPDFile(make, model, ppd)); - } - - cmd = "/usr/sbin/lpadmin -p " + printername; - if (printserver != null) - cmd = cmd.concat(" -s " + printserver); - if (device != null) { - cmd = cmd.concat(" -v " + device); - - if (device.indexOf("://") != -1) - cmd = cmd.concat(" -m uri"); - else { - if (destination != null) - cmd = cmd.concat(" -m netstandard"); - else - cmd = cmd.concat(" -m standard"); - if (ppd != null) - cmd = cmd.concat("_foomatic"); - } - } - if (printertype != null) - cmd = cmd.concat(" -T " + printertype); - if (notify != null) - cmd = cmd.concat(" -A " + notify); - if (ppdfile != null) { - cmd = cmd.concat(" -n " + ppdfile); - } - - - if (destination != null) - cmd = cmd.concat(" -o dest=" + destination); - if (protocol != null) - cmd = cmd.concat(" -o protocol=" + protocol); - if (banner != null) - cmd = cmd.concat(" -o banner=" + banner); - - if ((file_contents != null) && (file_contents.length != 0)) { - String tmpstr = file_contents[0]; - for (int i = 1; i < file_contents.length; i++) { - tmpstr = tmpstr.concat("," + file_contents[i]); - } - cmd = cmd.concat(" -I " + tmpstr); - } else { - cmd = cmd.concat(" -I postscript"); - } - if ((user_allow_list != null) && (user_allow_list.length != 0)) { - String tmpstr = user_allow_list[0]; - for (int i = 1; i < user_allow_list.length; i++) { - tmpstr = tmpstr.concat("," + user_allow_list[i]); - } - cmd = cmd.concat(" -u allow:" + tmpstr); - } - - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - syscmd = null; - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } else { - p.setWarnLog(err); - } - syscmd = null; - - // - // lpadmin won't take allow and deny lists together - // so do the deny seperately. - // - if ((user_deny_list != null) && (user_deny_list.length != 0)) { - String tmpstr = user_deny_list[0]; - for (int i = 1; i < user_deny_list.length; i++) { - tmpstr = tmpstr.concat("," + user_deny_list[i]); - } - cmd = "/usr/sbin/lpadmin -p " + printername + - " -u deny:" + tmpstr; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - if ((comment != null) && (!comment.equals(""))) { - // - // Have to use a command array here since - // exec(String) doesn't parse quoted strings. - // - String cmd_array[] = - { "/usr/sbin/lpadmin", "-p", printername, - "-D", comment }; - cmd = "/usr/sbin/lpadmin -p " + printername + " -D " + - "\"" + comment + "\""; - p.setCmdLog(cmd); - - syscmd = new SysCommand(); - syscmd.exec(cmd_array); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // If this is the default printer set it. - // If it fails warn user. - if (default_printer) { - cmd = "/usr/sbin/lpadmin -d " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // Check to see if we should enable it. - // If it fails warn user. - if (enable) { - cmd = "/usr/bin/enable " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - // Check to see if we should accept it. - // If it fails warn user. - if (accept) { - cmd = "/usr/sbin/accept " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - doFilters(p); - - // - // Take care of name service now. - // - if (!nameservice.equals("system")) { - try { - DoPrinterNS.set("add", p, ns); - } - catch (Exception e) { - p.clearLogs(); - NameService localns = new NameService(); - // - // Back out the local printer. - // - try { - DoPrinterDelete.delete(p, localns); - } - catch (Exception e2) { - Debug.message("SVR:" + e2.getMessage()); - } - p.clearLogs(); - throw (e); - } - } - return; - } - - // - // Do the work of adding a remote printer. - // - private static void addRemote( - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterAdd.addRemote()"); - - int exitvalue = 0; - String err = null; - String cmd = ""; - String cmd_array[] = new String[7]; - SysCommand syscmd = null; - - String printername = p.getPrinterName(); - String printserver = p.getPrintServer(); - String comment = p.getComment(); - boolean default_printer = p.getIsDefaultPrinter(); - String nameservice = ns.getNameService(); - - boolean isnismaster = false; - if (nameservice.equals("nis")) { - // - // Find out if we are the nis master - // - String nshost = ns.getNameServiceHost(); - Host h = new Host(); - String lh = h.getLocalHostName(); - if (lh.equals(nshost)) - 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. - // - if ((!nameservice.equals("system")) && (!isnismaster)) { - DoPrinterNS.set("add", p, ns); - return; - } - - cmd_array[0] = "/usr/sbin/lpadmin"; - cmd_array[1] = "-p"; - cmd_array[2] = printername; - cmd_array[3] = "-s"; - cmd_array[4] = printserver; - - if ((comment != null) && (!comment.equals(""))) { - cmd_array[5] = "-D"; - cmd_array[6] = comment; - } - - // - // Fix up cmd so we can log it. - // - for (int i = 0; i < cmd_array.length; i++) { - if (cmd_array[i] == null) - continue; - if (i == 6) { - cmd = cmd.concat("\"" + comment + "\""); - continue; - } - cmd = cmd.concat(cmd_array[i] + " "); - } - - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd_array); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - - // If this is the default printer set it. - // If it fails warn user. - if (default_printer) { - cmd = "/usr/sbin/lpadmin -d " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // - // If it's nis and we are here then we are the nis - // master. This call will do the make for us. - // - if (nameservice.equals("nis")) { - try { - DoPrinterNS.set("add", p, ns); - } - catch (Exception e) { - p.clearLogs(); - try { - // - // Back out the local printer. - // - DoPrinterDelete.delete(p, ns); - } - catch (Exception e2) - { - Debug.message("SVR:" + e2.getMessage()); - } - p.clearLogs(); - throw e; - } - } - return; - } - - - // - // Configure filters - // Look in /etc/lp/fd and configure each filter if it hasn't - // already been configured. We'll add warning messages if - // there are problems but don't consider anything here fatal. - // - private static void doFilters(Printer p) throws Exception - { - Debug.message("SVR: DoPrinterAdd.doFilters()"); - - int i = 0; - int j = 0; - String o = null; - String err = null; - String cmd = null; - String psfilters[] = null; - SysCommand syscmd = null; - - // - // Get list of potential filters - // - cmd = "/usr/bin/ls /etc/lp/fd"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - syscmd = null; - return; - } - o = syscmd.getOutput(); - syscmd = null; - if (o == null) { - return; - } - - StringTokenizer st = new StringTokenizer(o); - if (st.countTokens() == 0) { - return; - } - psfilters = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - psfilters[i] = st.nextToken(); - } - // - // Remove .fd suffix and empty slots that aren't filters. - // - for (i = 0; i < psfilters.length; i++) { - if (psfilters[i].endsWith(".fd")) { - j = psfilters[i].indexOf(".fd"); - psfilters[i] = psfilters[i].substring(0, j); - } else { - psfilters[i] = ""; - } - } - - // Get list of currently configured filters - cmd = "/usr/sbin/lpfilter -l -f all"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - - o = null; - if (syscmd.getExitValue() != 0) { - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - return; - } else { - o = syscmd.getOutput(); - } - - for (i = 0; i < psfilters.length; i++) { - if (psfilters[i].equals("")) - continue; - - // If we have filters see if this one is - // already configured. - if (o != null) { - if (o.indexOf("\"" + psfilters[i] + "\"") > -1) - continue; - } - - // Add the filter - cmd = "/usr/sbin/lpfilter -f " + psfilters[i] + - " -F /etc/lp/fd/" + psfilters[i] + ".fd"; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - - if (syscmd.getExitValue() != 0) { - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - } - syscmd = null; - } - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterDelete.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterDelete.java deleted file mode 100644 index ceeb721d84..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterDelete.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * DoPrinterDelete class - * Worker class for deleting a printer. - */ - -package com.sun.admin.pm.server; - -import java.io.*; - -public class DoPrinterDelete { - - // - // main for testing - // - public static void main(String[] args) { - - Printer p = null; - try { - NameService ns = new NameService(); - - p = new Printer(ns); - p.setPrinterName("javatest"); - - delete(p, ns); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - System.out.println("Commands:\n" + p.getCmdLog()); - System.out.println("Errors:\n" + p.getErrorLog()); - System.out.println("Warnings:\n" + p.getWarnLog()); - System.exit(0); - } - - // - // Interface to Printer object. - // - public static void delete( - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterDelete.delete()"); - - boolean success = true; - String err = null; - String cmd = null; - SysCommand syscmd = null; - - String printername = p.getPrinterName(); - String nameservice = ns.getNameService(); - - boolean islocal = DoPrinterUtil.isLocal(printername); - - // Take care of locally installed case first. - if (islocal) { - // See if printer is already rejected. - // Don't disable so queue can drain. - Printer curr = new Printer(); - curr.setPrinterName(printername); - try { - DoPrinterView.view(curr, ns); - } - catch (Exception e) { - Debug.message("SVR:" + e.getMessage()); - curr.setAccept(false); - } - - if (curr.getAccept()) { - cmd = "/usr/sbin/reject " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - curr = null; - try { - deleteLocal(p); - } - catch (Exception e) { - Debug.message("SVR:" + e.getMessage()); - success = false; - } - } - - // - // Check if we already removed it from /etc/printers.conf - // - boolean exists; - exists = DoPrinterUtil.exists(printername, "system"); - if (nameservice.equals("system")) { - if (exists) { - try { - deleteLocal(p); - } - catch (Exception e) { - Debug.message("SVR:" + e.getMessage()); - success = false; - } - } - } else { - if ((nameservice.equals("nis")) && exists) { - // - // Special case if we are nis master - // - Host h = new Host(); - String nshost = ns.getNameServiceHost(); - String lh = h.getLocalHostName(); - if (lh.equals(nshost)) { - try { - deleteLocal(p); - } - catch (Exception e) { - Debug.message("SVR:" + e.getMessage()); - success = false; - } - } - h = null; - } - DoPrinterNS.set("delete", p, ns); - } - if (!success) { - throw new pmException(); - } - return; - } - - private static void deleteLocal(Printer p) throws Exception - { - Debug.message("SVR: DoPrinterDelete.deleteLocal()"); - - String cmd = null; - String err = null; - SysCommand syscmd = null; - String printername = null; - - printername = p.getPrinterName(); - - // Workaround for lpadmin bug not removing default - String def = DoPrinterUtil.getDefault("system"); - if ((def != null) && (def.equals(printername))) { - cmd = "/usr/sbin/lpadmin -x _default"; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - cmd = "/usr/sbin/lpadmin -x " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (err != null) { - p.setWarnLog(err); - } - if (syscmd.getExitValue() != 0) { - syscmd = null; - throw new pmException(err); - } - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterMod.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterMod.java deleted file mode 100644 index b7cadaa1cb..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterMod.java +++ /dev/null @@ -1,841 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - */ - -package com.sun.admin.pm.server; - -import java.io.*; - -public class DoPrinterMod { - - // - // main for testing - // - public static void main(String[] args) { - NameService ns = new NameService(); - - String[] arr; - arr = new String[1]; - - Printer p = new Printer(); - - p.setPrinterName("javatest"); - p.setPrinterType("hplaser"); - p.setPrintServer("zelkova"); - p.setComment("This is a new comment"); - p.setDevice("/var/tmp/test"); - p.setNotify("none"); - p.setProtocol("bsd"); - p.setDestination(""); - p.setIsDefaultPrinter(true); - p.setBanner("never"); - p.setEnable(true); - p.setAccept(false); - - arr[0] = "any"; - p.setFileContents(arr); - arr[0] = "one"; - p.setUserAllowList(arr); - arr[0] = "two"; - p.setUserDenyList(arr); - - p.setLocale(null); - - try { - modify(p, ns); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - System.out.println("Commands:\n" + p.getCmdLog()); - System.out.println("Errors:\n" + p.getErrorLog()); - System.out.println("Warnings:\n" + p.getWarnLog()); - System.exit(0); - - } - - // - // Interface to Printer object. - // - public static void modify( - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterMod.modify()"); - - Printer curr = new Printer(ns); - curr.setPrinterName(p.getPrinterName()); - try { - DoPrinterView.view(curr, ns); - } - catch (Exception e) { - String err = curr.getErrorLog(); - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } - - boolean islocal = DoPrinterUtil.isLocal(p.getPrinterName()); - if (islocal) { - modifyLocal(p, curr, ns); - } else { - modifyRemote(p, curr, ns); - } - return; - } - - // - // Do the work of modifying a local printer. - // - private static void modifyLocal( - Printer p, - Printer curr, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterMod.modifyLocal()"); - - String err = null; - String cmd = null; - SysCommand syscmd = null; - - // Since it's local set extensions - // Eventually the gui should do this. - p.setExtensions("Solaris"); - - String nameservice = ns.getNameService(); - - String printername = p.getPrinterName(); - String printertype = null; - String printserver = null; - String comment = null; - String device = null; - String notify = null; - String make = null; - String model = null; - String ppd = null; - String protocol = null; - String destination = null; - String[] file_contents = null; - String[] user_allow_list = null; - String[] user_deny_list = null; - boolean default_printer = false; - String banner = null; - 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; - - String ppdfile = null; - - - // - // Set the things that have changed. - // - if (!strings_equal(curr.getPrinterType(), p.getPrinterType())) - printertype = p.getPrinterType(); - if (!strings_equal(curr.getComment(), p.getComment())) { - comment = p.getComment(); - if (comment == null) { - // Comment changed to empty. - p.setComment(""); - comment = ""; - } - } - if (!strings_equal(curr.getDevice(), p.getDevice())) - device = p.getDevice(); - - if (!strings_equal(curr.getNotify(), p.getNotify())) - notify = p.getNotify(); - - if (!strings_equal(curr.getProtocol(), p.getProtocol())) { - 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 - if (((protocol == null) && (curr.getProtocol() == "uri")) || - ((protocol != null) && (protocol.equals("uri")))) { - isURI = true; - } - Debug.message("SVR:DoPrinterMod:isURI: " + isURI); - Debug.message("SVR:DoPrinterMod:protocol: " + protocol); - Debug.message( - "SVR:DoPrinterMod:curr.getProtocol(): " + curr.getProtocol()); - Debug.message("SVR:DoPrinterMod:p.getProtocol(): " + p.getProtocol()); - - if (!strings_equal(curr.getDestination(), p.getDestination())) - destination = p.getDestination(); - - if ((!strings_equal(curr.getMake(), p.getMake())) || - (!strings_equal(curr.getModel(), p.getModel())) || - (!strings_equal(curr.getPPD(), p.getPPD()))) { - - model = p.getModel(); - make = p.getMake(); - ppd = p.getPPD(); - } - - - if (curr.getIsDefaultPrinter() != p.getIsDefaultPrinter()) { - default_printer = p.getIsDefaultPrinter(); - default_printer_changed = true; - } - if (curr.getEnable() != p.getEnable()) { - enable = p.getEnable(); - enable_changed = true; - } - - if (curr.getIsDefaultPrinter() != p.getIsDefaultPrinter()) { - default_printer = p.getIsDefaultPrinter(); - default_printer_changed = true; - } - if (curr.getEnable() != p.getEnable()) { - enable = p.getEnable(); - enable_changed = true; - } - - if (curr.getIsDefaultPrinter() != p.getIsDefaultPrinter()) { - default_printer = p.getIsDefaultPrinter(); - default_printer_changed = true; - } - if (curr.getEnable() != p.getEnable()) { - enable = p.getEnable(); - enable_changed = true; - } - if (curr.getAccept() != p.getAccept()) { - accept = p.getAccept(); - accept_changed = true; - } - if (!strings_equal(curr.getBanner(), p.getBanner())) { - banner = p.getBanner(); - banner_req_changed = true; - } - - if (!arrays_equal(curr.getFileContents(), p.getFileContents())) - file_contents = p.getFileContents(); - - if (!arrays_equal(curr.getUserAllowList(), p.getUserAllowList())) { - allow_changed = true; - // If the current value is "none" and the new - // value is null nothing is changing. - String[] arr = curr.getUserAllowList(); - if ((arr != null) && (arr.length != 0)) { - if (arr[0].equals("none")) { - if (p.getUserAllowList() == null) { - allow_changed = false; - } - } - } - } - if (!arrays_equal(curr.getUserDenyList(), p.getUserDenyList())) { - allow_changed = true; - } - if (allow_changed) { - user_allow_list = p.getUserAllowList(); - user_deny_list = p.getUserDenyList(); - } - - // - // Return if nothing changed. - // - if ((printertype == null) && - (comment == null) && - (device == null) && - (notify == null) && - (protocol == null) && - (destination == null) && - (make == null) && - (model == null) && - (ppd == 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) { - cmd = "/usr/sbin/lpadmin -d " + printername; - } else { - cmd = "/usr/sbin/lpadmin -x _default"; - } - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // - // If this is only a default printer change then possibly - // update the name service and return. - if ((printertype == null) && - (comment == null) && - (device == null) && - (notify == null) && - (protocol == null) && - (destination == null) && - (make == null) && - (model == null) && - (ppd == null) && - (file_contents == null) && - (!allow_changed) && - (!enable_changed) && - (!accept_changed) && - (!banner_req_changed)) { - if (nameservice.equals("system")) { - return; - } - p.modhints = "defaultonly"; - - DoPrinterNS.set("modify", p, ns); - p.modhints = ""; - return; - } - - // - // Do enable/accept - // - if (enable_changed) { - if (p.getEnable() == true) { - cmd = "/usr/bin/enable " + printername; - } else { - cmd = "/usr/bin/disable " + printername; - } - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - if (accept_changed) { - if (p.getAccept() == true) { - cmd = "/usr/sbin/accept " + printername; - } else { - cmd = "/usr/sbin/reject " + printername; - } - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - - // - // Do some slight of hand to deal with overloading of destination - // with device for uri protocol - // Done at the last moment to prevent modifying logic for old/new - // properties of the queue - - if (isURI) { - if (destination != null) - device = destination; - else - device = curr.getDestination(); - destination = null; - protocol = null; - } else { - if (protocol != null) { - device = "/dev/null"; - } - } - - - - // - // Build the modify command - // - - cmd = "/usr/sbin/lpadmin -p " + printername; - - if (printername != null) - if (DoPrinterUtil.isLocalhost(printername)) { - cmd = cmd.concat(" -s localhost"); - Debug.message("SVR:DoModifyPrinter:isLocalhost:true"); - } - - if (device != null) { - cmd = cmd.concat(" -v " + device); - } - - // Network printer - if (isURI) { - cmd = cmd.concat(" -m uri"); - - } else if (protocol != null) { - - if (curr.getPPD() != null) - cmd = cmd.concat(" -m netstandard_foomatic"); - else - cmd = cmd.concat(" -m netstandard"); - } - - if (printertype != null) - cmd = cmd.concat(" -T " + printertype); - - if (ppd != null) { - ppdfile = new String(DoPrinterUtil.getPPDFile(make, - model, ppd)); - - Debug.message("SVR:modifyLocal:ppdfile: " + ppdfile); - - cmd = cmd.concat(" -n " + ppdfile); - } - - if (notify != null) - cmd = cmd.concat(" -A " + notify); - - // 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) { - cmd = cmd.concat(" -o dest="); - cmd = cmd.concat(" -o protocol="); - } else { - if (destination != null) - cmd = cmd.concat(" -o dest=" + destination); - if (protocol != null) - cmd = cmd.concat(" -o protocol=" + protocol); - } - - if ((file_contents != null) && (file_contents.length != 0)) { - String tmpstr = file_contents[0]; - for (int i = 1; i < file_contents.length; i++) { - tmpstr = tmpstr.concat("," + file_contents[i]); - } - cmd = cmd.concat(" -I " + tmpstr); - } - - if (banner_req_changed) { - if (banner != null) { - cmd = cmd.concat(" -o banner=" + banner); - } - } - - // - // Has any of the above changed. - // - if (!cmd.equals("/usr/sbin/lpadmin -p " + printername)) { - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // - // If the user allow list changed delete all then re-add - // - if (allow_changed) { - cmd = "/usr/sbin/lpadmin -p " + printername + - " -u allow:none"; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - - if ((user_deny_list != null) && - (user_deny_list.length != 0)) { - String tmpstr = user_deny_list[0]; - for (int i = 1; i < user_deny_list.length; i++) { - tmpstr = tmpstr.concat("," - + user_deny_list[i]); - } - cmd = "/usr/sbin/lpadmin -p " + printername + - " -u deny:" + tmpstr; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - if ((user_allow_list != null) && - (user_allow_list.length != 0) && - (!user_allow_list[0].equals("none"))) { - String tmpstr = user_allow_list[0]; - for (int i = 1; i < user_allow_list.length; i++) { - tmpstr = tmpstr.concat("," - + user_allow_list[i]); - } - cmd = "/usr/sbin/lpadmin -p " + printername + - " -u allow:" + tmpstr; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - } - - if (comment != null) { - // - // Have to use a command array here since - // exec(String) doesn't parse quoted strings. - // Use lpadmin so the comment in /etc/printers.conf - // and /etc/lp/printers/comment stay in sync. - // - String cmd_array[] = - { "/usr/sbin/lpadmin", "-D", - comment, "-p", printername }; - cmd = "/usr/sbin/lpadmin -D " + - "\"" + comment + "\"" + " -p " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd_array); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - if (comment.equals("")) { - // - // LPADMIN BUG. Comment not cleared in printers.conf - // so force it with lpset. - // - cmd = "/usr/bin/lpset -a description= " + printername; - syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - err = syscmd.getError(); - p.setWarnLog(err); - } - syscmd = null; - } - } - - // - // Return if we don't need to touch the name service. - // - if (nameservice.equals("system")) { - return; - } - if ((comment == null) && (!default_printer_changed)) { - return; - } - - DoPrinterNS.set("modify", p, ns); - return; - } - - // - // Do the work of modifying a remote printer. - // - private static void modifyRemote( - Printer p, - Printer curr, - NameService ns) throws Exception - { - int exitvalue = 0; - String err = null; - String cmd = null; - String cmd_array[] = new String[4]; - SysCommand syscmd = null; - - String printername = null; - String printserver = null; - String comment = null; - String extensions = null; - boolean default_printer = false; - boolean default_printer_changed = false; - - String nameservice = ns.getNameService(); - - printername = p.getPrinterName(); - if (!strings_equal(curr.getPrintServer(), p.getPrintServer())) - printserver = p.getPrintServer(); - - if (!strings_equal(curr.getComment(), p.getComment())) { - comment = p.getComment(); - if (comment == null) { - // The comment changed to empty. - p.setComment(""); - comment = ""; - } - } -// -// Don't support extensions in the gui yet. -// If they exist leave them alone. -// EXTENSIONS - p.setExtensions(curr.getExtensions()); - if (!strings_equal(curr.getExtensions(), p.getExtensions())) - extensions = p.getExtensions(); - if (curr.getIsDefaultPrinter() != p.getIsDefaultPrinter()) { - default_printer = p.getIsDefaultPrinter(); - default_printer_changed = true; - } - - // - // Return if nothing changed. - // - if ((printserver == null) && - (extensions == null) && - (comment == null) && - (!default_printer_changed)) { - return; - } - - // - // If this is only a default printer change then set modhints - // - if ((printserver == null) && - (extensions == null) && - (comment == null)) { - p.modhints = "defaultonly"; - } - - - // - // Find out if we are the nis master - // - boolean isnismaster = false; - if (nameservice.equals("nis")) { - String nshost = ns.getNameServiceHost(); - Host h = new Host(); - String lh = h.getLocalHostName(); - if (lh.equals(nshost)) - isnismaster = true; - h = null; - } - - // - // If we are not updating system and we are not the nis - // master then update the name service and return. - // - if ((!nameservice.equals("system")) && (!isnismaster)) { - DoPrinterNS.set("modify", p, ns); - 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 != null) || (extensions != null)) { - // If printserver is null we are changing - // extensions. Set printserver to its current - // value. - if (printserver == null) { - printserver = curr.getPrintServer(); - } - String bsdaddr = "bsdaddr=" + printserver + "," - + printername; - // - // Leave the extensions alone - // EXTENSIONS - // - extensions = curr.getExtensions(); - if (extensions != null) { - bsdaddr = bsdaddr.concat("," + extensions); - } - cmd = "/usr/bin/lpset -a " + bsdaddr + " " + printername; - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - if (comment != null) { - cmd = "/usr/bin/lpset" + " -a description=" + - "\"" + comment + "\"" + - " " + printername; - cmd_array[0] = "/usr/bin/lpset"; - cmd_array[1] = "-a"; - cmd_array[2] = "description=" + comment; - cmd_array[3] = printername; - - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd_array); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // If this is the default printer set it. - if (default_printer_changed) { - if (default_printer) { - cmd = "/usr/sbin/lpadmin -d " + printername; - } else { - cmd = "/usr/sbin/lpadmin -x _default"; - } - p.setCmdLog(cmd); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } - if (err != null) { - p.setWarnLog(err); - } - syscmd = null; - } - - // - // If it's nis and we are here then we are the nis - // master. This call will do the make for us. - // - if (nameservice.equals("nis")) { - DoPrinterNS.set("modify", p, ns); - } - return; - } - - private static boolean arrays_equal(String[] arr1, String[] arr2) - { - if ((arr1 == null) && (arr2 == null)) { - return (true); - } - if ((arr1 == null) || (arr2 == null)) { - return (false); - } - if (arr1.length != arr2.length) { - return (false); - } - - int i, j; - String str; - boolean found; - for (i = 0; i < arr1.length; i++) { - found = false; - str = arr1[i]; - for (j = 0; j < arr2.length; j++) { - if (str.equals(arr2[j])) { - found = true; - } - } - if (found == false) { - return (false); - } - } - return (true); - } - - private static boolean strings_equal(String str1, String str2) - { - if ((str1 == null) && (str2 == null)) { - return (true); - } - if ((str1 == null) || (str2 == null)) { - return (false); - } - - return (str1.equals(str2)); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterNS.c b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterNS.c deleted file mode 100644 index 2cd059860d..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterNS.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -#pragma ident "%Z%%M% %I% %E% SMI" -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* LINTLIBRARY */ - -#include <stdio.h> -#include <strings.h> -#include <libintl.h> -#include "com_sun_admin_pm_server_DoPrinterNS.h" - -jstring glob_jstdout = NULL; -jstring glob_jstderr = NULL; - -extern char glob_stdout[]; -extern char glob_stderr[]; - -void set_stderr(JNIEnv *env); -void set_stdout(JNIEnv *env); -extern int _dorexec( - const char *host, - const char *user, - const char *passwd, - const char *cmd, - const char *locale); - -extern int _updateoldyp( - const char *action, - const char *printername, - const char *printserver, - const char *extensions, - const char *comment, - const char *isdefault); - -extern int _updateldap( - const char *action, - const char *host, - const char *user, - const char *passwd, - const char *printername, - const char *printserver, - const char *extensions, - const char *comment, - const char *isdefault); - -JNIEXPORT jint JNICALL -Java_com_sun_admin_pm_server_DoPrinterNS_dorexec( - JNIEnv *env, - jclass class, - jstring jhost, - jstring juser, - jstring jpasswd, - jstring jcmd, - jstring jlocale) -{ - const char *host; - const char *user; - const char *passwd; - const char *cmd; - const char *locale; - - int ret = 0; - jstring empty = (*env)->NewStringUTF(env, ""); - glob_jstdout = (*env)->NewGlobalRef(env, empty); - glob_jstderr = (*env)->NewGlobalRef(env, empty); - - host = (*env)->GetStringUTFChars(env, jhost, 0); - user = (*env)->GetStringUTFChars(env, juser, 0); - passwd = (*env)->GetStringUTFChars(env, jpasswd, 0); - cmd = (*env)->GetStringUTFChars(env, jcmd, 0); - locale = (*env)->GetStringUTFChars(env, jlocale, 0); - - ret = _dorexec(host, user, passwd, cmd, locale); - - if (ret != 0) { - (void) set_stderr(env); - return (ret); - } - (void) set_stderr(env); - (void) set_stdout(env); - return (ret); -} - -JNIEXPORT jstring JNICALL -Java_com_sun_admin_pm_server_DoPrinterNS_getstderr(JNIEnv *env, jclass class) -{ - return (glob_jstderr); -} - -JNIEXPORT jstring JNICALL -Java_com_sun_admin_pm_server_DoPrinterNS_getstdout(JNIEnv *env, jclass class) -{ - return (glob_jstdout); -} - -void -set_stderr(JNIEnv *env) -{ - static jstring jerrstr; - static char errbuf[BUFSIZ]; - - if (*glob_stderr == '\0') { - (void) strcpy(errbuf, ""); - } else { - (void) strcpy(errbuf, glob_stderr); - } - - jerrstr = (*env)->NewStringUTF(env, ""); - if (glob_jstderr != NULL) { - (*env)->DeleteGlobalRef(env, glob_jstderr); - } - - jerrstr = (*env)->NewStringUTF(env, errbuf); - glob_jstderr = (*env)->NewGlobalRef(env, jerrstr); -} - -void -set_stdout(JNIEnv *env) -{ - static jstring joutstr; - static char outbuf[BUFSIZ]; - - if (*glob_stdout == '\0') { - (void) strcpy(outbuf, ""); - } else { - (void) strcpy(outbuf, glob_stdout); - } - - joutstr = (*env)->NewStringUTF(env, ""); - if (glob_jstdout != NULL) { - (*env)->DeleteGlobalRef(env, glob_jstdout); - } - - joutstr = (*env)->NewStringUTF(env, outbuf); - glob_jstdout = (*env)->NewGlobalRef(env, joutstr); -} - -JNIEXPORT jint JNICALL -Java_com_sun_admin_pm_server_DoPrinterNS_updateoldyp( - JNIEnv *env, - jclass class, - jstring jaction, - jstring jprintername, - jstring jprintserver, - jstring jextensions, - jstring jcomment, - jstring jisdefault) -{ - const char *action = NULL; - const char *printername = NULL; - const char *printserver = NULL; - const char *extensions = NULL; - const char *comment = NULL; - const char *isdefault = NULL; - - int ret = 0; - jstring empty = (*env)->NewStringUTF(env, ""); - glob_jstdout = (*env)->NewGlobalRef(env, empty); - glob_jstderr = (*env)->NewGlobalRef(env, empty); - - action = (*env)->GetStringUTFChars(env, jaction, 0); - printername = (*env)->GetStringUTFChars(env, jprintername, 0); - if (jprintserver != NULL) { - printserver = - (*env)->GetStringUTFChars(env, jprintserver, 0); - } - if (jextensions != NULL) { - extensions = - (*env)->GetStringUTFChars(env, jextensions, 0); - } - if (jcomment != NULL) { - comment = - (*env)->GetStringUTFChars(env, jcomment, 0); - } - isdefault = (*env)->GetStringUTFChars(env, jisdefault, 0); - - ret = _updateoldyp(action, printername, printserver, - extensions, comment, isdefault); - - if (ret != 0) { - (void) set_stderr(env); - return (ret); - } - (void) set_stderr(env); - (void) set_stdout(env); - return (ret); -} - -JNIEXPORT jint JNICALL -Java_com_sun_admin_pm_server_DoPrinterNS_updateldap( - JNIEnv *env, - jclass class, - jstring jaction, - jstring jhost, - jstring jbinddn, - jstring jpasswd, - jstring jprintername, - jstring jprintserver, - jstring jextensions, - jstring jcomment, - jstring jisdefault) -{ - const char *action = NULL; - const char *host = NULL; - const char *binddn = NULL; - const char *passwd = NULL; - const char *printername = NULL; - const char *printserver = NULL; - const char *extensions = NULL; - const char *comment = NULL; - const char *isdefault = NULL; - - int ret = 0; - jstring empty = (*env)->NewStringUTF(env, ""); - glob_jstdout = (*env)->NewGlobalRef(env, empty); - glob_jstderr = (*env)->NewGlobalRef(env, empty); - - action = (*env)->GetStringUTFChars(env, jaction, 0); - printername = (*env)->GetStringUTFChars(env, jprintername, 0); - if (jhost != NULL) { - host = (*env)->GetStringUTFChars(env, jhost, 0); - } - if (jbinddn != NULL) { - binddn = (*env)->GetStringUTFChars(env, jbinddn, 0); - } - if (jpasswd != NULL) { - passwd = (*env)->GetStringUTFChars(env, jpasswd, 0); - } - if (jprintserver != NULL) { - printserver = - (*env)->GetStringUTFChars(env, jprintserver, 0); - } - if (jextensions != NULL) { - extensions = - (*env)->GetStringUTFChars(env, jextensions, 0); - } - if (jcomment != NULL) { - comment = - (*env)->GetStringUTFChars(env, jcomment, 0); - } - isdefault = (*env)->GetStringUTFChars(env, jisdefault, 0); - - ret = _updateldap(action, host, binddn, passwd, printername, - printserver, extensions, comment, isdefault); - - if (ret != 0) { - (void) set_stderr(env); - return (ret); - } - (void) set_stderr(env); - (void) set_stdout(env); - return (ret); -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterNS.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterNS.java deleted file mode 100644 index 3fdb9753ee..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterNS.java +++ /dev/null @@ -1,626 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * DoPrinterNS class - * Worker class for updating name services. - * Interfaces to JNI code. - */ - -package com.sun.admin.pm.server; - -public class DoPrinterNS -{ - // - // JNI member functions - // - private synchronized static native int dorexec(String nshost, - String user, String passwd, String cmd, String locale); - private synchronized static native int updateoldyp(String action, - String printername, String printserver, String extensions, - String comment, String isdefault); - private synchronized static native int updateldap(String action, - String host, String binddn, String passwd, - String printername, String printserver, String extensions, - String comment, String isdefault); - private synchronized static native String getstderr(); - private synchronized static native String getstdout(); - - // - // Load JNI. - // - static - { - System.loadLibrary("pmgr"); - } - - // - // main for testing - // - public static void main(String[] args) { - // - // Set attributes for testing. - // - NameService ns = null; - try { - ns = new NameService("nis"); - } - catch (Exception e) { - System.out.println(e); - System.exit(1); - } - ns.setPasswd(""); - - Printer p = new Printer(ns); - p.setPrinterName("javatest"); - p.setPrintServer("zelkova"); - p.setComment("This is a comment"); - p.setIsDefaultPrinter(false); - p.setLocale(null); - - String action = "add"; - if (args.length >= 1) - action = args[0]; - try { - set(action, p, ns); - } - catch (Exception e) { - System.out.println(e); - } - System.out.println("Commands:\n" + p.getCmdLog()); - System.out.println("Errors:\n" + p.getErrorLog()); - System.out.println("Warnings:\n" + p.getWarnLog()); - System.exit(0); - } - - // - // Interface to DoPrinter[add|mod|delete] - // - public static void set( - String action, - Printer p, - NameService ns) throws Exception - { - String nameservice = ns.getNameService(); - - if (nameservice.equals("system")) { - return; - } else if (nameservice.equals("nis")) { - setNIS(action, p, ns); - return; - } - setNS(action, p, ns); - return; - } - - private static void setNIS( - String action, - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterNS.setNIS(): " + action); - - String printername = p.getPrinterName(); - String printserver = p.getPrintServer(); - String comment = p.getComment(); - String extensions = p.getExtensions(); - boolean default_printer = p.getIsDefaultPrinter(); - String locale = p.getLocale(); - if (locale == null) - locale = "C"; - - String nameservice = ns.getNameService(); - String nshost = ns.getNameServiceHost(); - String user = ns.getUser(); - String passwd = ns.getPasswd(); - - String cmd = null; - String err = null; - int ret = 0; - int exitvalue = 0; - - // - // If this is the nis master we only need to do the make - // locally. - // - Host h = new Host(); - String lh = h.getLocalHostName(); - if (lh.equals(nshost)) { - cmd = "/usr/ccs/bin/make -f /var/yp/Makefile"; - cmd = cmd.concat(" -f /usr/lib/print/Makefile.yp "); - cmd = cmd.concat("printers.conf"); - - p.setCmdLog(cmd); - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else { - // ignore touch warning - // p.setWarnLog(err); - } - syscmd = null; - return; - } - - String cmdprefix = "rexec(" + nshost + "): "; - - cmd = "/usr/bin/echo"; - Debug.message("SVR: " + cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - if (ret != 0) { - throw new pmAuthException(getstderr()); - } - // - // Do we have lpset - // - cmd = "/usr/bin/ls /usr/bin/lpset"; - Debug.message("SVR: " + cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - if (ret != 0) { - throw new pmCmdFailedException(getstderr()); - } - String tmpstr = getstdout(); - tmpstr = tmpstr.trim(); - if (!tmpstr.equals("/usr/bin/lpset")) { - Debug.message("SVR: No lpset found. Checking rhosts."); - - // Are we set up in rhosts? - cmd = "rsh "; - cmd = cmd.concat(nshost); - cmd = cmd.concat(" echo"); - - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - syscmd = null; - throw new pmAuthRhostException(err); - } - syscmd = null; - // - // We don't have lpset. Must be pre-2.6 master. - // We are set up in rhosts so use libprint - // to update it. - // - p.setCmdLog("rsh " + nshost + "..."); - String def = "false"; - if (default_printer) - def = "true"; - - Debug.message("SVR: updateoldyp(): "); - Debug.message("SVR: action=" + action); - Debug.message("SVR: printername=" + printername); - Debug.message("SVR: printserver=" + printserver); - Debug.message("SVR: extensions=" + extensions); - Debug.message("SVR: comment=" + comment); - Debug.message("SVR: default=" + def); - - ret = updateoldyp(action, printername, - printserver, extensions, comment, def); - if (ret != 0) { - throw new pmCmdFailedException("libprint"); - } - return; - } - - // - // Add and modify are the same - // - boolean domake = false; - if (!action.equals("delete")) { - // - // If we are here from a modify and only need - // to change the default printer ... - // - if (!p.modhints.equals("defaultonly")) { - String bsdaddr = "bsdaddr=" + printserver + "," + - printername; - if (extensions != null) { - bsdaddr = bsdaddr.concat("," + extensions); - } - cmd = "/usr/bin/lpset -a " + bsdaddr; - if (comment != null) { - cmd = cmd.concat(" -a " + "description=" + - "\"" + comment + "\""); - } - cmd = cmd.concat(" " + printername); - - Debug.message("SVR: " + cmdprefix + cmd); - p.setCmdLog(cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - err = getstderr(); - if (ret != 0) { - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } - if (!err.equals("")) { - p.setWarnLog(err); - } - domake = true; - } - - cmd = null; - String def = DoPrinterUtil.getDefault("nis"); - if (default_printer) { - if (!printername.equals(def)) { - cmd = "/usr/bin/lpset -a " + "use=" + - printername + " _default"; - } - } else { - if ((def != null) && (def.equals(printername))) { - // - // It was the default but not any more. - // - cmd = "/usr/bin/lpset -x _default"; - } - } - if (cmd != null) { - Debug.message("SVR: " + cmdprefix + cmd); - p.setCmdLog(cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - err = getstderr(); - if (ret != 0) { - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } - if (!err.equals("")) { - p.setWarnLog(err); - } - domake = true; - } - } else { - if (DoPrinterUtil.exists(printername, "nis")) { - // delete - cmd = "/usr/bin/lpset -x " + printername; - Debug.message("SVR: " + cmdprefix + cmd); - p.setCmdLog(cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - err = getstderr(); - if (ret != 0) { - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } - if (!err.equals("")) { - p.setWarnLog(err); - } - domake = true; - } - String def = DoPrinterUtil.getDefault("nis"); - if ((def != null) && (def.equals(printername))) { - cmd = "/usr/bin/lpset -x _default"; - Debug.message("SVR: " + cmdprefix + cmd); - p.setCmdLog(cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - err = getstderr(); - if (ret != 0) { - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } - if (!err.equals("")) { - p.setWarnLog(err); - } - domake = true; - } - } - if (!domake) { - return; - } - - cmd = "cd /var/yp; /usr/ccs/bin/make -f /var/yp/Makefile"; - cmd = cmd.concat(" -f /usr/lib/print/Makefile.yp printers.conf"); - Debug.message("SVR: " + cmdprefix + cmd); - p.setCmdLog(cmdprefix + cmd); - ret = dorexec(nshost, user, passwd, cmd, locale); - err = getstderr(); - if (ret != 0) { - p.setErrorLog(err); - throw new pmCmdFailedException(err); - } - if (!err.equals("")) { - p.setWarnLog(err); - } - return; - } - - private static void setNS( - String action, - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterNS.setNS(): " + action); - - String printername = p.getPrinterName(); - String printserver = p.getPrintServer(); - String extensions = p.getExtensions(); - String comment = p.getComment(); - boolean default_printer = p.getIsDefaultPrinter(); - - String nameservice = ns.getNameService(); - - String nshost = ns.getNameServiceHost(); - String user = ns.getUser(); - String passwd = ns.getPasswd(); - - int exitvalue; - SysCommand syscmd = null; - String err; - String cmd = null; - String cmd_log = null; - String cmd_array[] = new String[14]; - - int index = 0; - String base_cmd = "/usr/bin/lpset -n " + nameservice; - String base_cmd_log = "/usr/bin/lpset -n " + nameservice; - - cmd_array[index++] = "/usr/bin/lpset"; - cmd_array[index++] = "-n"; - cmd_array[index++] = nameservice; - - /* - * Use jni to update ldap since the passwd is sensitive. - */ - if (nameservice.equals("ldap")) { - - if ((nshost == null) || (nshost.equals(""))) { - throw new pmInternalErrorException( - "Missing LDAP host for ldap operation"); - } - if ((user == null) && (user.equals(""))) { - throw new pmInternalErrorException( - "Missing Binddn for ldap operation"); - } - if ((passwd == null) && (passwd.equals(""))) { - throw new pmInternalErrorException( - "Missing passwd for ldap operation"); - } - - p.setCmdLog("ldap ..."); - - String def = "false"; - if (default_printer) - def = "true"; - - Debug.message("SVR: updateldap(): "); - Debug.message("SVR: action=" + action); - Debug.message("SVR: host=" + nshost); - Debug.message("SVR: binddn=" + user); - Debug.message("SVR: passwd=****"); - Debug.message("SVR: printername=" + printername); - Debug.message("SVR: printserver=" + printserver); - Debug.message("SVR: extensions=" + extensions); - Debug.message("SVR: comment=" + comment); - Debug.message("SVR: default=" + def); - - exitvalue = updateldap(action, nshost, user, passwd, - printername, printserver, extensions, comment, - def); - - if (exitvalue != 0) { - throw new pmCmdFailedException("libprint"); - } - return; - } - - // - // Add and modify are the same - // - if (!action.equals("delete")) { - // - // If we are here for a modify and we're only setting - // the default printer ... - // - if (!p.modhints.equals("defaultonly")) { - String bsdaddr = "bsdaddr=" + printserver + "," + - printername; - if (extensions != null) { - bsdaddr = bsdaddr.concat("," + extensions); - } - cmd_array[index++] = "-a"; - cmd_array[index++] = bsdaddr; - cmd_log = base_cmd_log + " -a " + bsdaddr; - if (comment != null) { - cmd_array[index++] = "-a"; - cmd_array[index++] = "description=" + comment; - cmd_log = cmd_log.concat(" -a " + - "description=" + "\"" + comment + "\""); - } - cmd_array[index++] = printername; - cmd_log = cmd_log.concat(" " + printername); - - p.setCmdLog(cmd_log); - syscmd = new SysCommand(); - syscmd.exec(cmd_array); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else { - p.setWarnLog(err); - } - syscmd = null; - } - cmd = null; - cmd_log = null; - String args = null; - String def = DoPrinterUtil.getDefault(nameservice); - if (default_printer) { - if (!printername.equals(def)) { - args = " -a " + "use=" + printername + - " _default"; - cmd = base_cmd + args; - cmd_log = base_cmd_log + args; - } - } else { - if ((def != null) && (def.equals(printername))) { - // - // It was the default but not any more. - // - args = " -x _default"; - cmd = base_cmd + args; - cmd_log = base_cmd_log + args; - } - } - if (cmd != null) { - p.setCmdLog(cmd_log); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else { - p.setWarnLog(err); - } - syscmd = null; - } - } else { - if (DoPrinterUtil.exists(printername, nameservice)) { - // delete - cmd = base_cmd + " -x " + printername; - cmd_log = base_cmd_log + " -x " + printername; - p.setCmdLog(cmd_log); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else { - p.setWarnLog(err); - } - syscmd = null; - - } - String def = DoPrinterUtil.getDefault(nameservice); - if ((def != null) && (def.equals(printername))) { - cmd = base_cmd + " -x _default"; - cmd_log = base_cmd_log + " -x _default"; - p.setCmdLog(cmd_log); - syscmd = new SysCommand(); - syscmd.exec(cmd); - err = syscmd.getError(); - if (syscmd.getExitValue() != 0) { - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } else { - p.setWarnLog(err); - } - syscmd = null; - } - } - return; - } - - public static boolean doAuth(NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterNS.checkAuth()"); - - String nsname = ns.getNameService(); - String host = ns.getNameServiceHost(); - String user = ns.getUser(); - String passwd = ns.getPasswd(); - - if (nsname.equals("system")) { - if (!isRoot()) { - Debug.error( - "SVR: User does not have root priveleges."); - throw new pmAuthException(); - } - } else if (nsname.equals("nis")) { - Host h = new Host(); - String lh = h.getLocalHostName(); - String nm = h.getNisHost("master"); - if (lh.equals(nm)) { - // Since we are on the NIS master the - // check is the same as for "system". - Debug.message("SVR: Host is NIS master."); - if (!isRoot()) { - Debug.error( - "SVR: User does not have root access."); - throw new pmAuthException(); - } - } - int ret = dorexec(host, user, passwd, "/usr/bin/echo", "C"); - if (ret != 0) { - Debug.error( - "SVR: User does not have NIS update access."); - throw new pmAuthException(getstderr()); - } - } else if (nsname.equals("ldap")) { - int ret = updateldap("add", host, user, passwd, - "_pmTestAuthToken", null, null, null, "false"); - - if (ret != 0) { - Debug.error( - "SVR: User does not have LDAP update priveleges."); - throw new pmAuthException(); - } - ret = updateldap("delete", host, user, passwd, - "_pmTestAuthToken", null, null, null, "false"); - - } else { - throw new pmInternalErrorException( - "doAuth(): Invalid name service: " + nsname); - } - return (true); - } - - public static void doCheckRootPasswd(String p) - throws Exception - { - Host h = new Host(); - String lh = h.getLocalHostName(); - - int ret = dorexec(lh, "root", p, "/usr/bin/echo", "C"); - if (ret != 0) { - throw new pmAuthException(getstderr()); - } - return; - } - - public static boolean isRoot() - throws Exception - { - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/id", "LC_ALL=C"); - - String o = syscmd.getOutput(); - - if (o == null) { - throw new pmCmdFailedException(syscmd.getError()); - } - if (o.indexOf("uid=0(") == -1) { - return (false); - } - return (true); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterUtil.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterUtil.java deleted file mode 100644 index 6d8790a55c..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterUtil.java +++ /dev/null @@ -1,557 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - * - * DoPrinterUtil class - * Worker utility class. - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -public class DoPrinterUtil { - - public static String getDefault(String ns) throws Exception - { - Debug.message("SVR: DoPrinterUtil.getDefault()"); - Debug.message("SVR: name service equals " + ns); - - String o = null; - String cmd = "/usr/bin/lpget -n " + ns + " _default"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - o = syscmd.getOutput(); - syscmd = null; - - if (o == null) { - return (null); - } - int i = o.indexOf("use="); - if (i == -1) { - return (null); - } - o = o.substring(i); - String dflt = DoPrinterView.getToken(o + "\n", "use="); - - Debug.message("SVR: default is " + dflt); - return (new String(dflt)); - } - - public static String[] getDevices() throws Exception - { - Debug.message("SVR: DoPrinterUtil.getDevices()"); - - int i = 0; - String dev = ""; - String devices = ""; - - String serial_possibilities[] = {"a", "b", "c", "d", - "e", "f", "g", "h", "i", "j", "k", "l", "m", - "n", "o", "p", "q", "r", "s", "t", "u", "v", - "w", "x", "y", "z"}; - - String cmd = "/usr/bin/find /dev -print"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - - String o = syscmd.getOutput(); - syscmd = null; - - if (o == null) { - return (null); - } - o = o.concat("\n"); - - for (i = 0; i < serial_possibilities.length; i++) { - dev = "/dev/term/" + serial_possibilities[i] + "\n"; - if (o.indexOf(dev) != -1) { - devices = devices.concat(" " + dev + " "); - } - } - // sparc bpp parallel ports - for (i = 0; i < 100; i++) { - dev = "/dev/bpp" + i + "\n"; - if (o.indexOf(dev) != -1) { - devices = devices.concat(" " + dev + " "); - } - } - // sparc ecpp parallel ports - for (i = 0; i < 100; i++) { - dev = "/dev/ecpp" + i + "\n"; - if (o.indexOf(dev) != -1) { - devices = devices.concat(" " + dev + " "); - } - } - // intel parallel ports - for (i = 0; i < 100; i++) { - dev = "/dev/lp" + i + "\n"; - if (o.indexOf(dev) != -1) { - devices = devices.concat(" " + dev + " "); - } - } - - // USB - for (i = 0; i < 100; i++) { - dev = "/dev/printers/" + i + "\n"; - if (o.indexOf(dev) != -1) { - devices = devices.concat(" " + dev + " "); - } - } - - // SunPics - dev = "/dev/lpvi\n"; - if (o.indexOf(dev) != -1) { - devices = devices.concat(" " + dev + " "); - } - - o = null; - - if (devices.equals("")) { - return (null); - } - - String ret[]; - StringTokenizer st = new StringTokenizer(devices); - if (st.countTokens() == 0) { - return (null); - } else { - ret = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - ret[i] = st.nextToken(); - } - } - return (ret); - } - - public static String[] getMakes() throws Exception - { - int i; - - Debug.message("SVR: DoPrinterUtil.getMakes()"); - - String cmd = "/usr/lib/lp/bin/getmakes"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - String makes = syscmd.getOutput(); - - String ret[]; - StringTokenizer st = new StringTokenizer(makes); - if (st.countTokens() == 0) { - return (null); - } else { - ret = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - ret[i] = st.nextToken(); - - } - } - return (ret); - - } - public static String[] getModels(String make) throws Exception - { - int i; - String ret[]; - - Debug.message("SVR:getModels()"); - - if (make == null) { - Debug.message("SVR:getModels: make is null"); - return (null); - } - // Make call for models for this make - String cmd = "/usr/lib/lp/bin/getmodels " + make; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - String models = syscmd.getOutput(); - - if (models != null) { - StringTokenizer st = new StringTokenizer(models, "\n"); - if (st.countTokens() == 0) { - Debug.message("SVR:String tokenizer count is zero"); - return (null); - } else { - ret = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - ret[i] = st.nextToken(); - - } - } - return (ret); - } else - return (null); - } - - public static String[] getPPDs(String make, String model) throws Exception - { - int i; - String ret[]; - ret = new String[2]; - if ((make == null) || (model == null)) { - return null; - } - // get ppd files for this make/model - String cmd = "/usr/lib/lp/bin/getppds " + make + " " + model; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - String ppds = syscmd.getOutput(); - StringTokenizer st = new StringTokenizer(ppds, "\n"); - if (st.countTokens() == 0) { - return (null); - } else { - ret = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - ret[i] = st.nextToken(); - - } - } - return (ret); - } - - public static String[] getMakeModelNick(String ppdfilename) throws Exception - { - int i; - String ret[] = null; - if (ppdfilename == null) { - return (null); - } - // get ppd files for this make/model - String cmd = "/usr/lib/lp/bin/ppdfilename2mmp " + ppdfilename; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - String mmp = syscmd.getOutput(); - - if (mmp != null) { - ret = new String[2]; - - StringTokenizer st = new StringTokenizer(mmp, "\n"); - if (st.countTokens() == 0) { - return (null); - } else { - ret = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - ret[i] = st.nextToken(); - - } - } - } - return (ret); - } - - public static String getPPDFile( - String make, String model, String ppd) throws Exception - { - int i; - String ret[]; - ret = new String[2]; - if (ppd == null) { - return (null); - } - // get ppd path/filename for this ppd - String cmd = "/usr/lib/lp/bin/getppdfile " + - make + ":" + " " + model + ":" + " " + ppd + ":"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - String ppdfile = syscmd.getOutput(); - - return (ppdfile); - } - - - public static String[] getProbe(String device) - { - int i; - String pmake = null; - String pmodel = null; - String tokens[] = null; - String ret[]; - ret = new String[2]; - - if (device == null) - return (null); - - Debug.message("SVR: DoPrinterUtil.getProbe()"); - - // Get Manufacturer and Model for printer in this port - String cmd = "/usr/lib/lp/bin/printer-info -M -m " + device; - SysCommand syscmd = new SysCommand(); - try { - syscmd.exec(cmd); - } catch (Exception e) { - System.out.println(e); - } - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - return (null); - } - - String mm = syscmd.getOutput(); - if (mm != null) { - int numtokens; - StringTokenizer st = new StringTokenizer(mm, ":" + "\n"); - if (st.countTokens() == 0) { - return (null); - } else { - numtokens = st.countTokens(); - tokens = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - tokens[i] = st.nextToken(); - } - } - for (i = 0; i < numtokens; i++) { - if ((tokens[i].trim()).equals("Manufacturer")) { - pmake = new String(tokens[i + 1].trim()); - } else { if ((tokens[i].trim()).equals("Model")) - pmodel = new String(tokens[i + 1].trim()); - } - } - - if (pmake != null) - ret[0] = pmake; - if (pmodel != null) - ret[1] = pmodel; - - return (ret); - } - return (null); - - } - - public static boolean isMakeModel( - String make, - String model) - { - int exitvalue; - - Debug.message("SVR: DoPrinterUtil.isMakeModel() " + make + " " + model); - - SysCommand syscmd = new SysCommand(); - // syscmd.exec("/usr/bin/lpget -n " + ns + " " + name); - exitvalue = syscmd.getExitValue(); - syscmd = null; - if (exitvalue == 0) { - return (true); - } - return (false); - } - - - public static String[] getList(String nsarg) - throws Exception - { - Debug.message("SVR: DoPrinterUtil.getList()"); - - int i = 0; - int j = 0; - int listi = 0; - - String cmd = null; - String printername = ""; - String printserver = ""; - String comment = ""; - String nameservice; - String list[]; - - String o = null; - cmd = "/usr/bin/lpget -n " + nsarg + " list"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String errstr = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(errstr); - } - o = syscmd.getOutput(); - syscmd = null; - - if (o == null) { - return (null); - } - - // Count entries - int index = 0; - while ((index = o.indexOf("bsdaddr=", index)) != -1) { - index = index + 8; - i++; - } - if (i <= 0) - return (null); - - list = new String [i*3]; - - int colon = 0; - int nextcolon = 0; - while ((colon = o.indexOf(":\n", colon + 1)) != -1) { - nextcolon = o.indexOf(":\n", colon + 1); - if (nextcolon == -1) - nextcolon = o.length(); - // Extract printername - i = colon; - while ((o.charAt(i) != '\n') && (i != 0)) { - i--; - } - if (i == 0) - printername = o.substring(i, colon); - else - printername = o.substring(i + 1, colon); - - // Skip _all and _default keywords - if (printername.equals("_all")) { - continue; - } - if (printername.equals("_default")) { - continue; - } - - // Extract servername - i = o.indexOf("bsdaddr=", colon); - if ((i != -1) && (i < nextcolon)) { - j = o.indexOf(",", i); - if (j != -1) - printserver = o.substring(i + 8, j); - } - // Skip entries without a server. - if (printserver.equals("")) { - Debug.warning( - "SVR: printer does not have a server: " - + printername); - continue; - } - - // Extract description - i = o.indexOf("description=", colon); - if ((i != -1) && (i < nextcolon)) { - j = i; - while (j < o.length()) { - if (o.charAt(j) == '\n') - break; - j++; - } - comment = o.substring(i + 12, j); - } - - list[listi++] = printername; - list[listi++] = printserver; - list[listi++] = comment; - printername = ""; - printserver = ""; - comment = ""; - } - return (list); - } - - public static boolean exists( - String name, - String ns) throws Exception - { - int exitvalue; - - Debug.message("SVR: DoPrinterUtil.exists() " + ns); - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/lpget -n " + ns + " " + name); - exitvalue = syscmd.getExitValue(); - syscmd = null; - if (exitvalue == 0) { - return (true); - } - return (false); - } - - public static boolean isLocal( - String pn) throws Exception - { - int exitvalue; - - Debug.message("SVR: DoPrinterUtil.isLocal()"); - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/test -d /etc/lp/printers/" + pn); - exitvalue = syscmd.getExitValue(); - syscmd = null; - if (exitvalue != 0) { - return (false); - } - return (true); - } - - public static boolean isLocalhost( - String queue) throws Exception - { - int exitvalue; - String o = null; - - Debug.message("SVR: DoPrinterUtil.isLocalhost():queue " + queue); - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/grep " + queue + " /etc/printers.conf"); - exitvalue = syscmd.getExitValue(); - if (exitvalue != 0) { - Debug.message( - "SVR:DoPrinterUtil:isLocalhost:failed:queue: " + queue); - return (false); - } - o = syscmd.getOutput(); - syscmd = null; - Debug.message("SVR:DoPrinterUtil.java:isLocalhost: output: " + o); - if (o.indexOf("localhost") != -1) - return (true); - else - return (false); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterView.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterView.java deleted file mode 100644 index d3446bb6bd..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/DoPrinterView.java +++ /dev/null @@ -1,485 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * DoPrinterView class - * Worker class for gathering printer information. - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -import com.sun.admin.pm.client.pmNeedPPDCacheException; -import com.sun.admin.pm.client.pmCacheMissingPPDException; -// import com.sun.admin.pm.client.pmGuiException; - -public class DoPrinterView { - - public static void main(String[] args) { - Debug.setDebugLevel(Debug.ALL); - - Printer p = new Printer(); - p.setPrinterName("petite"); - NameService ns = new NameService(); - - try { - view(p, ns); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - PrinterDebug.printObj(p); - - System.out.println("Commands:\n" + p.getCmdLog()); - System.out.println("Errors:\n" + p.getErrorLog()); - System.out.println("Warnings:\n" + p.getWarnLog()); - System.exit(0); - } - - // - // Interface to Printer object. - // - public static void view( - Printer p, - NameService ns) throws Exception - { - boolean islocal = - DoPrinterUtil.isLocal(p.getPrinterName()); - if (islocal) { - viewLocal(p, ns); - } else { - viewRemote(p, ns); - } - - return; - } - - // - // Do the work getting Remote printer attributes. - // - private static void viewRemote( - Printer p, - NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterView.viewRemote()"); - - int exitvalue = 0; - int i, j; - String o = null; - String printername = p.getPrinterName(); - String printserver = null; - String comment = null; - String extensions = null; - boolean default_printer = false; - - String nsarg = ns.getNameService(); - - String err = null; - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/lpget -n " + nsarg + " " + - printername, "LC_ALL=C"); - - if (syscmd.getExitValue() != 0) { - err = syscmd.getError(); - p.setErrorLog(err); - // Add stdout since thats where lpget sends errors. - err = syscmd.getOutput(); - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } - o = syscmd.getOutput(); - syscmd = null; - - if (o == null) { - throw new pmCmdFailedException(err); - } - // For easier parsing. - o = o.concat("\n"); - - i = o.indexOf("bsdaddr="); - if (i == -1) { - Debug.message("SVR: Can't parse bsdaddr for " + printername); - throw new pmException(); - } - i = i + 8; - j = o.indexOf(",", i); - if (j == -1) { - Debug.message("SVR: Can't parse bsdaddr for " + printername); - throw new pmException(); - } - printserver = o.substring(i, j); - - i = o.indexOf(",Solaris"); - if (i != -1) { - extensions = "Solaris"; - } - - i = o.indexOf("description="); - if (i != -1) { - i = i + 12; - j = o.indexOf("\n", i); - if (j != -1) { - comment = o.substring(i, j); - } - } - - String def = DoPrinterUtil.getDefault(nsarg); - if ((def != null) && (def.equals(printername))) { - default_printer = true; - } - p.setPrintServer(printserver); - p.setExtensions(extensions); - p.setComment(comment); - p.setIsDefaultPrinter(default_printer); - return; - } - - // - // Do the work getting printer attributes. - // - private static void viewLocal( - Printer p, NameService ns) throws Exception - { - Debug.message("SVR: DoPrinterView.viewLocal()"); - - int i = -1; - int exitvalue = 0; - String str = null; - String o = null; - - String printername = p.getPrinterName(); - String printertype = null; - String printserver = null; - String comment = null; - String device = null; - String make = null; - String model = null; - String ppd = null; - String notify = null; - String protocol = null; - String destination = null; - String extensions = "Solaris"; - String[] file_contents = null; - String[] user_allow_list = null; - String[] user_deny_list = null; - boolean default_printer = false; - String banner = null; - boolean enable = false; - boolean accept = false; - - String ppdfile = null; - - String def = DoPrinterUtil.getDefault("system"); - if ((def != null) && (def.equals(printername))) { - default_printer = true; - } - - // - // Parse lpstat output - // - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/lpstat -L -l -a " + - printername + " -p " + printername, "LC_ALL=C"); - - if (syscmd.getExitValue() != 0) { - String err = syscmd.getError(); - p.setErrorLog(err); - syscmd = null; - throw new pmCmdFailedException(err); - } - - o = syscmd.getOutput(); - syscmd = null; - - // Append a newline to make parsing easier. - o = o.concat("\n"); - - comment = getToken(o, "\tDescription:"); - if (comment == null || comment.equals("")) { - comment = null; - } - - // Get the PPD path/filename from lpstat - // Get the make/model/ppd nickname using ppd-filename - ppdfile = getToken(o, "\tPPD:"); - if ((ppdfile == null) || (ppdfile.equals("none")) || - (ppdfile.equals(""))) { - ppdfile = null; - } else { - // Set the make/model/ppd - - if (!pmMisc.isppdCachefile()) { - throw new pmNeedPPDCacheException("ppdcache missing"); - } - String ret[]; - ret = new String[3]; - ret = DoPrinterUtil.getMakeModelNick(ppdfile); - - if ((ret != null) && (!ret.equals(""))) { - make = ret[0]; - model = ret[1]; - ppd = ret[2]; - } else { - throw new pmCacheMissingPPDException( - "PPD file not in cache"); - } - } - - int j = -1; - printserver = p.getPrintServer(); - - printertype = getToken(o, "Printer types:"); - i = o.indexOf("enabled since"); - if (i != -1) { - enable = true; - } - i = o.indexOf("not accepting requests"); - if (i == -1) { - accept = true; - } - - i = o.indexOf("Banner not required"); - if (i != -1) { - banner = "optional"; - } - i = o.indexOf("Banner required"); - if (i != -1) { - banner = "always"; - } - i = o.indexOf("Banner page never printed"); - if (i != -1) { - banner = "never"; - } - - - - // If we have Options then look for destination and protocol. - protocol = "bsd"; - str = "Options:"; - i = o.indexOf(str); - if (i != -1) { - // Set str to the substring containing only the options line. - j = o.indexOf("\n", i); - str = o.substring(i, j); - - // Append a comma to make parsing easier. - str = str.concat(","); - i = str.indexOf("dest="); - if (i != -1) { - i += 5; - j = str.indexOf(",", i); - destination = str.substring(i, j); - destination = destination.trim(); - } - i = str.indexOf("protocol="); - if (i != -1) { - i += 9; - j = str.indexOf(",", i); - protocol = str.substring(i, j); - protocol = protocol.trim(); - } - } - - StringTokenizer st; - - // Build array of content types. - str = getToken(o, "Content types:"); - if (str != null) { - str = str.replace(',', ' '); - st = new StringTokenizer(str); - if (st.countTokens() != 0) { - file_contents = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - file_contents[i] = st.nextToken(); - } - } - } - - // - // User allow list. - // - str = "Users allowed:\n"; - i = o.indexOf(str); - if (i != -1) { - i += str.length(); - // Grab the substring containing only users. - j = o.indexOf("\tForms"); - if (j != -1) { - str = o.substring(i, j); - st = new StringTokenizer(str); - if (st.countTokens() != 0) { - user_allow_list = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - user_allow_list[i] = st.nextToken(); - } - } - } - } - if (user_allow_list == null) { - } else if (user_allow_list[0].equals("(all)")) { - user_allow_list[0] = "all"; - } else if (user_allow_list[0].equals("(none)")) { - user_allow_list[0] = "none"; - } - // - // User deny list - // - syscmd = new SysCommand(); - String cmd = "/bin/cat /etc/lp/printers/" + printername + "/users.deny"; - syscmd.exec(cmd); - if (syscmd.getExitValue() == 0) { - str = syscmd.getOutput(); - if ((str != null) && (str.length() != 0)) { - st = new StringTokenizer(str); - if (st.countTokens() != 0) { - user_deny_list = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - user_deny_list[i] = st.nextToken(); - } - } - } - } - syscmd = null; - - // - // Get fault action - // - str = getToken(o, "On fault:"); - if (str != null) { - if (!str.equals("")) { - if (str.indexOf("write") != -1) { - notify = "write"; - } else if (str.indexOf("mail") != -1) { - notify = "mail"; - } else if (str.indexOf("no alert") != -1) { - notify = "none"; - } else if (str.indexOf("alert with") != -1) { - i = str.indexOf("\""); - if (i != -1) { - j = str.lastIndexOf("\""); - if (j > i) { - notify = str.substring(++i, j); - } - } - } else if (str.indexOf(" quiet ") != -1) { - notify = "quiet"; - } else { - notify = "unknown"; - } - } - } - syscmd = null; - // - // Get the printers device - // - syscmd = new SysCommand(); - syscmd.exec("/usr/bin/lpstat -L -v " + printername, - "LC_ALL=C"); - - o = syscmd.getOutput(); - if (o != null) { - o = o.concat("\n"); - device = getToken(o, ":"); - } - - Debug.message("SVR: DEVICE (" + device + ")"); - // - // If the device is in URI form (scheme:// ...), set the protocol - // for the "network attached" modify screen. - // - if (device != null && device.indexOf("://") != -1) { - protocol = "uri"; - destination = device; - device = null; - } - - syscmd = null; - - p.setPrinterType(printertype); - p.setPrintServer(printserver); - p.setFileContents(file_contents); - p.setComment(comment); - p.setDevice(device); - p.setMake(make); - p.setModel(model); - p.setPPD(ppd); - p.setPPDFile(ppdfile); - p.setNotify(notify); - p.setProtocol(protocol); - p.setDestination(destination); - p.setExtensions(extensions); - p.setIsDefaultPrinter(default_printer); - p.setBanner(banner); - p.setEnable(enable); - p.setAccept(accept); - p.setUserAllowList(user_allow_list); - p.setUserDenyList(user_deny_list); - - if (ns.getNameService().equals("system")) - return; - Debug.message( - "SVR: Overlaying name service attributes on local printer"); - try { - viewRemote(p, ns); - } - catch (Exception e) - { - Debug.warning( - "SVR: Overlay of name service attributes failed."); - Debug.warning("SVR: " + e.getMessage()); - } - return; - } - - // - // Return substring starting at sub + 1 and ending with - // a newline. - // - public static String getToken(String str, String sub) - { - int i = -1; - int j = -1; - String result = null; - - i = str.indexOf(sub); - if (i != -1) { - if (str.charAt(i + sub.length()) == '\n') { - return (null); - } - i = i + sub.length(); - j = str.indexOf("\n", i); - if (j != -1) { - result = str.substring(i, j); - result = result.trim(); - } - } - return (result); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Host.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Host.java deleted file mode 100644 index 330d990b7b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Host.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Host class - * Methods associated with a host. - */ - -package com.sun.admin.pm.server; - -import java.io.*; - -public class Host -{ - public static void main(String[] args) - { - try { - System.out.println(getLocalHostName()); - System.out.println(getDomainName()); - System.out.println(getNisHost("master")); - } - catch (Exception e) { - System.out.println(e); - } - System.exit(0); - } - - // - // Get the local hostname - // Return an empty string if we don't find one. - // - public synchronized static String getLocalHostName() - throws Exception - { - Debug.message("SVR: Host.getLocalHostName()"); - - String cmd = "/usr/bin/hostname"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - - if (syscmd.getExitValue() != 0) { - String err = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(err); - } - String o = syscmd.getOutput(); - syscmd = null; - - if (o == null) - return (new String("")); - return (new String(o)); - } - - // - // Get the domainname - // Return an empty string if we don't find one. - // - public synchronized static String getDomainName() - throws Exception - { - Debug.message("SVR: Host.getDomainName()"); - - String cmd = "/usr/bin/domainname"; - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - String err = syscmd.getError(); - syscmd = null; - throw new pmCmdFailedException(err); - } - - String o = syscmd.getOutput(); - syscmd = null; - - if (o == null) - return (new String("")); - return (new String(o)); - } - - public synchronized static void pingHost(String host) - throws Exception - { - int exitvalue; - - Debug.message("SVR: Host.pingHost()"); - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/sbin/ping " + host); - exitvalue = syscmd.getExitValue(); - syscmd = null; - - if (exitvalue != 0) { - String err = syscmd.getError(); - throw new pmHostNotPingableException(err); - } - } - - public synchronized static String getNisMaster() - throws Exception - { - return (getNisHost("master")); - } - - // - // Look for the nis server. - // If we are looking for the master server first try - // the printers.conf.byname map. If that fails - // look for passwd. - // - public synchronized static String getNisHost(String type) - throws Exception - { - Debug.message("SVR: Host.getNisHost() " + type); - - SysCommand syscmd = null; - String cmd = null; - int exitvalue = 0; - - if (type.equals("master")) { - cmd = "/usr/bin/ypwhich -m printers.conf.byname"; - } else { - cmd = "/usr/bin/ypwhich"; - } - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - if ((exitvalue != 0) && (type.equals("master"))) { - Debug.message("SVR: printers.conf NIS host not found."); - Debug.message("SVR: Looking for NIS passwd host."); - cmd = "/usr/bin/ypwhich -m passwd"; - - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - } - if (exitvalue != 0) { - Debug.error("SVR: NIS server could not be found"); - String err = syscmd.getError(); - syscmd = null; - throw new pmNSNotConfiguredException(err); - } - - String o = syscmd.getOutput(); - syscmd = null; - - if (o == null) { - throw new pmCmdFailedException(syscmd.getError()); - } - o = o.trim(); - return (new String(o)); - } - - /* - * Return the name of the first server listed by ldapclient - */ - public synchronized static String getLDAPMaster() - throws Exception - { - SysCommand syscmd = null; - String cmd = null; - int exitvalue = 0; - - /* ldapclient will hang if we are not root. */ - if (!DoPrinterNS.isRoot()) { - Debug.error("SVR: Not root. Can't determine LDAP master."); - return null; - } - - cmd = "/usr/sbin/ldapclient list"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - - if (exitvalue != 0) { - Debug.error("SVR: ldapclient failed."); - Debug.error("SVR: " + syscmd.getError()); - syscmd = null; - return null; - } - String o = syscmd.getOutput(); - syscmd = null; - - String master = DoPrinterView.getToken(o + "\n", "NS_LDAP_SERVERS="); - if (master == null) { - Debug.error("SVR: ldapclient did not return NS_LDAP_SERVERS."); - syscmd = null; - return null; - } - - /* Extract the first address from the NS_LDAP_SERVERS list */ - - for (int i = 0; i < master.length(); i++) { - if ((master.charAt(i) == ',') || - (master.charAt(i) == ' ') || - (master.charAt(i) == '\t')) { - master = master.substring(0, i); - break; - } - } - master = master.trim(); - - return (new String(master)); - } - - /* - * Get a default admin DN. - */ - public synchronized static String getDefaultAdminDN() - throws Exception - { - SysCommand syscmd = null; - String cmd = null; - int exitvalue = 0; - - try { - String master = getLDAPMaster(); - cmd = "/usr/bin/ldapsearch -h " + master + - " -b o=NetScapeRoot o=NetscapeRoot"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - if (exitvalue == 0) { - String on = syscmd.getOutput(); - syscmd = null; - if (on != null) { - if (on.indexOf("NetscapeRoot") != -1) { - return ("cn=Directory Manager"); - } - } - } - syscmd = null; - } - catch (Exception e) { - Debug.message("SVR: ldapsearch for NSDS failed. Continuing"); - } - - cmd = "/usr/bin/ldaplist -d printers"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - - if (exitvalue != 0) { - Debug.error("SVR: ldaplist printers failed."); - Debug.error("SVR: " + syscmd.getError()); - syscmd = null; - return null; - } - String o = syscmd.getOutput(); - syscmd = null; - - if (o == null) { - return null; - } - - String dn = DoPrinterView.getToken(o + "\n", "ou=printers,"); - if (dn == null) { - return null; - } - dn = "cn=admin," + dn; - dn = dn.trim(); - - return (new String(dn)); - } - - // - // Check to see if a name service is configured - // - public synchronized static void isNSConfigured(String ns) - throws Exception - { - Debug.message("SVR: Host.isNSConfigured() " + ns); - - int exitvalue; - String cmd = null; - String err = null; - SysCommand syscmd = null; - - if (ns.equals("system")) { - return; - } else if (ns.equals("nis")) { - cmd = "/usr/bin/ypwhich"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - err = syscmd.getError(); - syscmd = null; - - if (exitvalue != 0) { - throw new pmNSNotConfiguredException(err); - } - - cmd = "/usr/bin/ypcat cred"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - syscmd = null; - if (exitvalue == 0) { - Debug.warning( - "SVR: Unable to update this configuration."); - throw new pmNSNotConfiguredException(); - } - } else if (ns.equals("ldap")) { - /* - * Check if the ldap-client is configured by first checking - * if the config file exists and then invoking ldaplist - * Note: we need to check if the config file exists before - * invoking ldaplist so that we don't get its error message - */ - - File ldapConfig = new File("/var/ldap/ldap_client_file"); - if (ldapConfig.isFile()) { - // Config file exists - - cmd = "/usr/bin/ldaplist -d printers"; - syscmd = new SysCommand(); - syscmd.exec(cmd); - exitvalue = syscmd.getExitValue(); - syscmd = null; - - if (exitvalue != 0) { - throw new pmNSNotConfiguredException(); - } - } else { - throw new pmNSNotConfiguredException(); - } - } else { - throw new pmInternalErrorException( - "Unkown name service " + ns); - } - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile deleted file mode 100644 index 690b18ccfa..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile +++ /dev/null @@ -1,126 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Makefile for Java Print Manager server -# - -LIBRARY = libpmgr.a -VERS = .1 - -JNIHDR_FILES = com_sun_admin_pm_server_DoPrinterNS.h - -OBJECTS = DoPrinterNS.o NS.o - -CLASSFILES = Printer.class \ - Host.class \ - SysCommand.class \ - NameService.class \ - PrinterUtil.class \ - DoPrinterView.class \ - DoPrinterAdd.class \ - DoPrinterDelete.class \ - DoPrinterUtil.class \ - DoPrinterMod.class \ - DoPrinterNS.class \ - Valid.class \ - Test.class \ - Debug.class \ - PrinterDebug.class \ - pmException.class \ - pmAuthException.class \ - pmAuthRhostException.class \ - pmCmdFailedException.class \ - pmInternalErrorException.class \ - pmHostNotPingableException.class \ - pmNSNotConfiguredException.class \ - pmMisc.class - -JNICLASSFILES = DoPrinterNS.class - -include $(SRC)/lib/Makefile.lib - -SRCDIR = . - -# There should be a mapfile here -MAPFILES = - -CLASSPATH= $(SRC)/cmd/print/printmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -ROOTDIRS = $(ROOT)/usr/sadm/admin \ - $(ROOT)/usr/sadm/admin/printmgr \ - $(ROOT)/usr/sadm/admin/printmgr/lib - -# override ROOTLIBDIR and ROOTLINKS -ROOTLIBDIR = $(ROOT)/usr/sadm/admin/printmgr/lib -ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%) - - -# Following variables define where to find header files -CPPFLAGS += -I$(JAVA_ROOT)/include -I$(JAVA_ROOT)/include/solaris -I. - -CERRWARN += -_gcc=-Wno-unused-variable -CERRWARN += -_gcc=-Wno-uninitialized - -LDLIBS += -lprint -lnsl -lsocket -lc - -CLEANFILES= *.class $(LINTLIB) $(LINTOUT) -CLOBBERFILES= $(JNIHDR_FILES) $(LIBLINKS) - -all: $(CLASSFILES) $(JNIHDR_FILES) $(DYNLIB) - -install: all $(ROOTDIRS) $(ROOTLINKS) - -# -# Build jni header file -# Use $@ instead of the "unreliable" $* -# -$(JNIHDR_FILES): $(JNICLASSFILES) - $(JAVAH) -jni -classpath $(CLASSPATH) \ - `echo $@ | sed 's/.h$$//' | tr _ .` - -# -# Build standalone programs for testing -# -NS: NS.c - $(CC) NS.c -g $(ILDOFF) -o NS -DMAIN=1 $(ENVLDLIBS1) $(ENVLIBS2) \ - -lprint -lnsl -lsocket - -lint: $(JNIHDR_FILES) lintcheck - -cstyle: - cstyle $(SRCS) - -jstyle: - jstyle $(JAVAFILES) - -_msg: - -$(ROOTDIRS): - $(INS.dir) - -include $(SRC)/lib/Makefile.targ diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/NS.c b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/NS.c deleted file mode 100644 index eeeefdd31c..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/NS.c +++ /dev/null @@ -1,821 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -#pragma ident "%Z%%M% %I% %E% SMI" -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/*LINTLIBRARY*/ - -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <netdb.h> -#include <unistd.h> -#include <stdlib.h> -#include <arpa/inet.h> -#include <rpcsvc/ypclnt.h> - -char glob_stdout[BUFSIZ]; -char glob_stderr[BUFSIZ]; - -void f_cleanup(FILE *fp, char *tmpf); -void fd_cleanup(int fd1, int fd2); -static void _freeList(char ***list); - -extern void **list_append(void **list, void *item); - -#ifdef MAIN - -#define THOSTNAME "cherwell" -#define TPRINTERNAME "c" - -int -main() { - char *host = THOSTNAME; - const char *user = "cn=Directory Manager"; - const char *passwd = "directorymanager"; - int result = 0; - - result = _updateldap("add", host, user, passwd, - "_pmTestAuthToken", NULL, NULL, "new comment", "false"); - if (result != 0) { - printf("Add 1 failed, err code = %d\n"); - } - - result = _updateldap("delete", host, user, passwd, - "_pmTestAuthToken", NULL, NULL, NULL, "false"); - if (result != 0) { - printf("Delete 1 failed, err code = %d\n"); - } - - result = _updateldap("delete", host, user, passwd, TPRINTERNAME, - THOSTNAME, "", "new comment", "true"); - if (result != 0) { - printf("delete failed, err code = %d\n"); - } - - result = _updateldap("delete", host, user, passwd, "_default", - THOSTNAME, "", "new comment", "true"); - if (result != 0) { - printf("delete failed, err code = %d\n"); - } - - result = _updateldap("add", host, user, passwd, TPRINTERNAME, - THOSTNAME, "Solaris", "new comment", "true"); - if (result != 0) { - printf("add failed, err code = %d\n"); - } - - result = _updateldap("modify", host, user, passwd, TPRINTERNAME, - THOSTNAME, "", "modified comment", "true"); - if (result != 0) { - printf("modify failed, err code = %d\n"); - } - - result = _updateldap("modify", host, user, passwd, TPRINTERNAME, - THOSTNAME, "", NULL, "false"); - if (result != 0) { - printf("modify failed, err code = %d\n"); - } - - - exit(0); -} -#endif - - -int -_dorexec( - const char *host, - const char *user, - const char *passwd, - const char *cmd, - const char *locale) { - - int ret = 0; - int fd = 0; - int fd2 = 1; - - FILE *fderr; - char *ferr; - - (void) memset(glob_stdout, 0, BUFSIZ); - (void) memset(glob_stderr, 0, BUFSIZ); - - /* - * Re-direct stderr to a file - */ - ferr = tempnam(NULL, NULL); - if (ferr != NULL) { - fderr = freopen(ferr, "w+", stderr); - } - - fd = rexec((char **)&host, htons(512), user, - passwd, cmd, &fd2); - - if (fd > -1) { - /* - * rexec worked. Clean up stderr file. - */ - f_cleanup(fderr, ferr); - - ret = read(fd, glob_stdout, BUFSIZ - 1); - if (ret < 0) { - (void) strncpy(glob_stderr, strerror(errno), - (BUFSIZ - 1)); - fd_cleanup(fd, fd2); - return (errno); - } - - ret = read(fd2, glob_stderr, BUFSIZ - 1); - if (ret < 0) { - (void) strncpy(glob_stderr, strerror(errno), - (BUFSIZ - 1)); - fd_cleanup(fd, fd2); - return (errno); - } - } else { - /* - * rexec failed. Read from the stderr file. - */ - if (fderr != NULL) { - char tmpbuf[BUFSIZ]; - - (void) rewind(fderr); - strcpy(glob_stderr, ""); - while (fgets(tmpbuf, BUFSIZ - 1, - fderr) != NULL) { - if ((strlen(glob_stderr) + - strlen(tmpbuf)) > BUFSIZ - 1) { - break; - } else { - (void) strcat(glob_stderr, tmpbuf); - } - } - } - f_cleanup(fderr, ferr); - fd_cleanup(fd, fd2); - return (1); - } - fd_cleanup(fd, fd2); - return (0); -} - -void -fd_cleanup(int fd, int fd2) -{ - if (fd > 0) { - (void) close(fd); - } - if (fd2 > 0) { - (void) close(fd2); - } -} - -void -f_cleanup(FILE *fp, char *tmpf) -{ - if (fp != NULL) { - (void) fclose(fp); - } - if (tmpf != NULL) { - (void) unlink(tmpf); - (void) free(tmpf); - } -} - -struct ns_bsd_addr { - char *server; /* server name */ - char *printer; /* printer name or NULL */ - char *extension; /* RFC-1179 conformance */ - char *pname; /* Local printer name */ -}; -typedef struct ns_bsd_addr ns_bsd_addr_t; - -/* Key/Value pair structure */ -struct ns_kvp { - char *key; /* key */ - void *value; /* value converted */ -}; -typedef struct ns_kvp ns_kvp_t; - -/* - * Information needed to update a name service. - * Currently only used for ldap. (see lib/print/ns.h) - */ - -/* LDAP bind password security type */ - -typedef enum NS_PASSWD_TYPE { - NS_PW_INSECURE = 0, - NS_PW_SECURE = 1 -} NS_PASSWD_TYPE; - - -struct ns_cred { - char *binddn; - char *passwd; - char *host; - int port; /* LDAP port, 0 = default */ - NS_PASSWD_TYPE passwdType; /* password security type */ - uchar_t *domainDN; /* NS domain DN */ -}; -typedef struct ns_cred ns_cred_t; - -/* LDAP specific NS Data */ - -typedef struct NS_LDAPDATA { - char **attrList; /* list of user defined Key Value Pairs */ -} NS_LDAPDATA; - -/* Printer Object structure */ -struct ns_printer { - char *name; /* primary name of printer */ - char **aliases; /* aliases for printer */ - char *source; /* name service derived from */ - ns_kvp_t **attributes; /* key/value pairs. */ - ns_cred_t *cred; /* info to update name service */ - void *nsdata; /* name service specific data */ -}; -typedef struct ns_printer ns_printer_t; - -extern ns_printer_t *ns_printer_get_name(const char *, const char *); -extern int ns_printer_put(const ns_printer_t *); -extern char *ns_get_value_string(const char *, const ns_printer_t *); -extern int ns_set_value(const char *, const void *, ns_printer_t *); -extern int ns_set_value_from_string(const char *, const char *, - ns_printer_t *); -extern ns_bsd_addr_t *bsd_addr_create(const char *, const char *, - const char *); -extern char *bsd_addr_to_string(const ns_bsd_addr_t *); -extern void ns_printer_destroy(ns_printer_t *); - -int -_updateoldyp( - const char *action, - const char *printername, - const char *printserver, - const char *extensions, - const char *comment, - const char *isdefault) { - - ns_printer_t *printer; - ns_bsd_addr_t *addr; - int status = 0; - - char mkcmd[BUFSIZ]; - char *domain = NULL; - char *host = NULL; - - /* - * libprint returns before we know that the printers.conf - * map is made. So we'll make it again. - */ - (void) yp_get_default_domain(&domain); - - if ((yp_master(domain, "printers.conf.byname", &host) != 0) && - (yp_master(domain, "passwd.byname", &host) != 0)) { - strcpy(mkcmd, "/usr/bin/sleep 1"); - } else { - sprintf(mkcmd, "/usr/bin/rsh -n %s 'cd /var/yp; " - "/usr/ccs/bin/make -f /var/yp/Makefile " - "-f /var/yp/Makefile.print printers.conf " - "> /dev/null'", host); - } - - if (strcmp(action, "delete") == 0) { - if ((printer = (ns_printer_t *) - ns_printer_get_name(printername, "nis")) == NULL) { - return (0); - } - - printer->attributes = NULL; - status = ns_printer_put(printer); - if (status != 0) { - (void) free(printer); - return (status); - } - - if ((printer = (ns_printer_t *) - ns_printer_get_name("_default", "nis")) != NULL) { - char *dflt = (char *) - ns_get_value_string("use", printer); - if ((dflt != NULL) && - (strcmp(dflt, printername) == 0)) { - printer->attributes = NULL; - status = ns_printer_put(printer); - if (status != 0) { - (void) free(printer); - return (status); - } - } - } - (void) free(printer); - (void) system(mkcmd); - return (0); - - } else if (strcmp(action, "add") == 0) { - printer = (ns_printer_t *)malloc(sizeof (*printer)); - memset(printer, 0, sizeof (*printer)); - printer->name = (char *)printername; - printer->source = "nis"; - - addr = (ns_bsd_addr_t *)malloc(sizeof (*addr)); - memset(addr, 0, sizeof (*addr)); - addr->printer = (char *)printername; - addr->server = (char *)printserver; - if ((extensions != NULL) && - (strlen(extensions) > 0)) { - addr->extension = (char *)extensions; - } - ns_set_value("bsdaddr", addr, printer); - - if ((comment != NULL) && (strlen(comment) > 0)) { - ns_set_value_from_string("description", - comment, printer); - } - status = ns_printer_put(printer); - if (status != 0) { - (void) free(addr); - (void) free(printer); - return (status); - } - - if (strcmp(isdefault, "true") == 0) { - printer->name = "_default"; - printer->attributes = NULL; - ns_set_value_from_string("use", printername, printer); - status = ns_printer_put(printer); - if (status != 0) { - (void) free(addr); - (void) free(printer); - return (status); - } - } - (void) free(addr); - (void) free(printer); - (void) system(mkcmd); - return (0); - } - - /* - * Modify - */ - if ((printer = (ns_printer_t *) - ns_printer_get_name(printername, "nis")) == NULL) { - return (1); - } - if ((comment != NULL) && (strlen(comment) > 0)) { - ns_set_value_from_string("description", comment, printer); - } else { - ns_set_value_from_string("description", - NULL, printer); - } - status = ns_printer_put(printer); - if (status != 0) { - (void) free(printer); - return (status); - } - - if ((printer = (ns_printer_t *) - ns_printer_get_name("_default", "nis")) != NULL) { - char *dflt = (char *)ns_get_value_string("use", printer); - if (strcmp(printername, dflt) == 0) { - if (strcmp(isdefault, "false") == 0) { - /* - * We were the default printer but not - * any more. - */ - printer->attributes = NULL; - status = ns_printer_put(printer); - if (status != 0) { - (void) free(printer); - return (status); - } - } - } else { - if (strcmp(isdefault, "true") == 0) { - ns_set_value_from_string("use", - printername, printer); - status = ns_printer_put(printer); - if (status != 0) { - (void) free(printer); - return (status); - } - } - } - } else { - printer = (ns_printer_t *)malloc(sizeof (*printer)); - memset(printer, 0, sizeof (*printer)); - printer->name = "_default"; - printer->source = "nis"; - ns_set_value_from_string("use", printername, printer); - status = ns_printer_put(printer); - if (status != 0) { - (void) free(printer); - return (status); - } - } - (void) system(mkcmd); - return (0); -} - -int -_updateldap( - const char *action, - const char *host, - const char *binddn, - const char *passwd, - const char *printername, - const char *printserver, - const char *extensions, - const char *comment, - const char *isdefault) - -{ - ns_printer_t *printer; - ns_bsd_addr_t *addr; - ns_cred_t *cred; - - char *item = NULL; - char **attrList = NULL; - - int status; - - if (printserver == NULL) { - /* printserver not given so use host */ - printserver = host; - } - - cred = (ns_cred_t *)malloc(sizeof (*cred)); - (void) memset(cred, '\0', sizeof (*cred)); - cred->passwd = strdup((char *)passwd); - cred->binddn = strdup((char *)binddn); - cred->host = strdup((char *)host); - - cred->passwdType = NS_PW_INSECURE; /* use default */ - cred->port = 0; /* use default */ - cred->domainDN = NULL; /* use default */ - - if (strcmp(action, "delete") == 0) { - /* - * Delete printer object from LDAP directory DIT - */ - - if ((printer = (ns_printer_t *) - ns_printer_get_name(printername, "ldap")) == NULL) { - return (0); - } - - printer->attributes = NULL; - printer->nsdata = malloc(sizeof (NS_LDAPDATA)); - if (printer->nsdata == NULL) { - return (1); - } - ((NS_LDAPDATA *)(printer->nsdata))->attrList = NULL; - printer->cred = cred; - printer->source = strdup("ldap"); - status = ns_printer_put(printer); - free(printer->nsdata); - (void) ns_printer_destroy(printer); - - if (status != 0) { - return (status); - } - - if ((printer = (ns_printer_t *) - ns_printer_get_name("_default", "ldap")) != NULL) { - char *dflt = (char *) - ns_get_value_string("use", printer); - if ((dflt != NULL) && - (strcmp(dflt, printername) == 0)) { - printer->attributes = NULL; - printer->nsdata = malloc(sizeof (NS_LDAPDATA)); - if (printer->nsdata == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - ((NS_LDAPDATA *)(printer->nsdata))->attrList = NULL; - printer->cred = cred; - printer->source = strdup("ldap"); - status = ns_printer_put(printer); - free(printer->nsdata); - if (status != 0) { - (void) ns_printer_destroy(printer); - return (status); - } - } - - (void) ns_printer_destroy(printer); - } - return (0); - - } else if (strcmp(action, "add") == 0) { - /* - * Add new printer object into LDAP directory DIT - */ - - printer = (ns_printer_t *)malloc(sizeof (*printer)); - if (printer == NULL) { - return (1); - } - (void) memset(printer, 0, sizeof (*printer)); - printer->name = strdup((char *)printername); - printer->source = strdup("ldap"); - - printer->cred = cred; - - /* set BSD address in attribute list */ - - if (extensions == NULL) { - item = (char *)malloc(strlen("bsdaddr") + - strlen(printserver) + - strlen(printername) + - strlen("Solaris") + 6); - } else { - item = (char *)malloc(strlen("bsdaddr") + - strlen(printserver) + - strlen(printername) + - strlen(extensions) + 6); - } - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - - if (extensions == NULL) { - sprintf(item, "%s=%s,%s,%s", "bsdaddr", - printserver, printername, "Solaris"); - } else { - sprintf(item, "%s=%s,%s,%s", "bsdaddr", - printserver, printername, extensions); - } - - attrList = (char **)list_append((void**)attrList, - (void *)item); - if ((comment != NULL) && (strlen(comment) > 0)) { - item = (char *)malloc(strlen("description") + - strlen(comment) + 4); - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - sprintf(item, "%s=%s", "description", comment); - attrList = (char **)list_append((void**)attrList, - (void *)item); - } - - printer->attributes = NULL; - printer->nsdata = malloc(sizeof (NS_LDAPDATA) + 2); - if (printer->nsdata == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - ((NS_LDAPDATA *)(printer->nsdata))->attrList = attrList; - - status = ns_printer_put(printer); - _freeList(&attrList); - if (status != 0) { - free(printer->nsdata); - (void) ns_printer_destroy(printer); - return (status); - } - - if (strcmp(isdefault, "true") == 0) { - (void) free(printer->name); - - printer->name = strdup("_default"); - printer->attributes = NULL; - - attrList = NULL; - item = (char *)malloc(strlen("use") + - strlen(printername) + 4); - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - sprintf(item, "%s=%s", "use", printername); - attrList = (char **)list_append((void**)attrList, - (void *)item); - - ((NS_LDAPDATA *)(printer->nsdata))->attrList = attrList; - - status = ns_printer_put(printer); - _freeList(&attrList); - free(printer->nsdata); - if (status != 0) { - (void) ns_printer_destroy(printer); - return (status); - } - } - (void) ns_printer_destroy(printer); - return (0); - } - - /* - * Modify printer object in the LDAP directory DIT - */ - - if ((printer = (ns_printer_t *) - ns_printer_get_name(printername, "ldap")) == NULL) { - return (1); - } - printer->cred = cred; - printer->source = strdup("ldap"); - - if ((comment != NULL) && (strlen(comment) > 0)) { - item = (char *)malloc(strlen("description") + - strlen(comment) + 4); - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - sprintf(item, "%s=%s", "description", comment); - attrList = (char **)list_append((void**)attrList, (void *)item); - } else { - item = (char *)malloc(strlen("description") + 4); - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - sprintf(item, "%s=", "description"); - attrList = (char **)list_append((void**)attrList, (void *)item); - } - - printer->attributes = NULL; - printer->nsdata = malloc(sizeof (NS_LDAPDATA)); - if (printer->nsdata == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - ((NS_LDAPDATA *)(printer->nsdata))->attrList = attrList; - - status = ns_printer_put(printer); - _freeList(&attrList); - free(printer->nsdata); - if (status != 0) { - (void) ns_printer_destroy(printer); - return (status); - } - - /* - * Handle the default printer. - */ - if ((printer = (ns_printer_t *) - ns_printer_get_name("_default", "ldap")) != NULL) { - char *dflt = (char *)ns_get_value_string("use", printer); - - printer->source = strdup("ldap"); - printer->cred = cred; - if (strcmp(printername, dflt) == 0) { - if (strcmp(isdefault, "false") == 0) { - /* - * We were the default printer but not - * any more. So delete the default entry - */ - printer->attributes = NULL; - printer->nsdata = malloc(sizeof (NS_LDAPDATA)); - if (printer->nsdata == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - ((NS_LDAPDATA *)(printer->nsdata))->attrList = NULL; - status = ns_printer_put(printer); - free(printer->nsdata); - if (status != 0) { - (void) ns_printer_destroy(printer); - return (status); - } - } - } else if (strcmp(isdefault, "true") == 0) { - /* - * Modify this default entry to use us. - */ - printer->attributes = NULL; - printer->nsdata = malloc(sizeof (NS_LDAPDATA)); - if (printer->nsdata == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - attrList = NULL; - item = (char *)malloc(strlen("use") + - strlen(printername) + 4); - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - sprintf(item, "%s=%s", "use", printername); - attrList = (char **)list_append((void**)attrList, - (void *)item); - - ((NS_LDAPDATA *)(printer->nsdata))->attrList = attrList; - - status = ns_printer_put(printer); - _freeList(&attrList); - free(printer->nsdata); - - if (status != 0) { - (void) ns_printer_destroy(printer); - return (status); - } - } - } else if (strcmp(isdefault, "true") == 0) { - /* - * No default entry existed and we need one. - */ - printer = (ns_printer_t *)malloc(sizeof (*printer)); - (void) memset(printer, 0, sizeof (*printer)); - printer->name = strdup("_default"); - printer->source = strdup("ldap"); - printer->cred = cred; - - printer->nsdata = malloc(sizeof (NS_LDAPDATA)); - if (printer->nsdata == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - - attrList = NULL; - item = (char *)malloc(strlen("use") + strlen(printername) + 4); - if (item == NULL) { - (void) ns_printer_destroy(printer); - return (1); - } - sprintf(item, "%s=%s", "use", printername); - attrList = (char **)list_append((void**)attrList, (void *)item); - - ((NS_LDAPDATA *)(printer->nsdata))->attrList = attrList; - - status = ns_printer_put(printer); - _freeList(&attrList); - free(printer->nsdata); - - if (status != 0) { - (void) ns_printer_destroy(printer); - return (status); - } - } - - (void) ns_printer_destroy(printer); - return (0); -} - - - - -/* - * ***************************************************************************** - * - * Function: _freeList() - * - * Description: Free the list created by list_append() where the items in - * the list have been strdup'ed. - * - * Parameters: - * Input: char ***list - returned set of kvp values - * - * Result: void - * - * ***************************************************************************** - */ - -static void -_freeList(char ***list) - -{ - int i = 0; - - /* ------ */ - - if (list != NULL) { - if (*list != NULL) { - for (i = 0; (*list)[i] != NULL; i++) { - free((*list)[i]); - } - free(*list); - } - - *list = NULL; - } -} /* _freeList */ diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/NameService.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/NameService.java deleted file mode 100644 index 8b3e874161..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/NameService.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * NameService class - * Methods and state associated with a name service. - */ - -package com.sun.admin.pm.server; - -import java.io.*; - -public class NameService -{ - private String nameservice = null; - private String nshost = null; - private String user = null; - private String passwd = null; - private boolean boundtonisslave = false; - private boolean isauth = false; - - // - // Constructors - // - // This constructor is used internally in the server package. - public NameService() - { - nameservice = "system"; - isauth = true; - } - // This constructor should always be used by the client. - public NameService(String nsname) throws Exception - { - if ((nsname.equals("system")) || - (nsname.equals("nis")) || - (nsname.equals("ldap"))) { - nameservice = nsname; - } else { - throw new pmInternalErrorException( - "Unknown name service: " + nsname); - } - - Host h = new Host(); - h.isNSConfigured(nameservice); - - if (nsname.equals("nis")) { - String nm = h.getNisHost("master"); - String nb = h.getNisHost("bound"); - if (!nm.equals(nb)) { - boundtonisslave = true; - } - setUser("root"); - setNameServiceHost(nm); - setPasswd(""); - } else if (nsname.equals("ldap")) { - String master = h.getLDAPMaster(); - if (master == null) { - setNameServiceHost(""); - } else { - setNameServiceHost(master); - } - - String admin = h.getDefaultAdminDN(); - if (admin == null) { - setUser(""); - } else { - setUser(admin); - } - - setPasswd(""); - } - - } - - public void setNameServiceHost(String arg) - { - nshost = arg; - } - public void setUser(String arg) - { - user = arg; - } - public void setPasswd(String arg) - { - passwd = arg; - } - - public String getNameService() - { - return (nameservice); - } - public String getNameServiceHost() - { - return (nshost); - } - public String getUser() - { - return (user); - } - public String getPasswd() - { - return (passwd); - } - public boolean getBoundToNisSlave() - { - return (boundtonisslave); - } - public boolean isAuth() - { - return (isauth); - } - - public void checkAuth() throws Exception - { - Debug.message("SVR: NameService.checkAuth()"); - - DoPrinterNS.doAuth(this); - isauth = true; - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Printer.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Printer.java deleted file mode 100644 index 1f75989a3c..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Printer.java +++ /dev/null @@ -1,497 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Printer class - * Printer object containing attributes and methods for - * updating printers. - */ - -package com.sun.admin.pm.server; - -public class Printer -{ - // - // Printer object attributes - // - private String printername = null; - private String printertype = null; - private String printserver = null; - private String comment = null; - private String device = null; - private String make = null; - private String model = null; - private String ppd = null; - private String ppdfile = null; - private String notify = null; - private String protocol = null; - private String destination = null; - private String extensions = null; - private String[] file_contents = null; - private String[] user_allow_list = null; - private String[] user_deny_list = null; - private boolean use_ppd_file = true; - private boolean default_printer = false; - private String banner = null; - private boolean enable = true; - private boolean accept = true; - - private String locale = null; // Possible future use - - private NameService nscontext; - - // - // Logs - // - private String warnlog = null; - private String errlog = null; - private String cmdlog = null; - - // - // Constructors - // - public Printer() - { - Debug.message("SVR: Printer constructor called empty."); - nscontext = new NameService(); - PrinterDebug.printObj(nscontext); - } - public Printer(NameService ns) - { - Debug.message("SVR: Printer constructor called with NS."); - nscontext = ns; - PrinterDebug.printObj(ns); - } - - // - // Is a printer local to this machine - // - public synchronized boolean isPrinterLocal(String printername) - throws Exception - { - Debug.message("SVR: Printer.isPrinterLocal()"); - return (DoPrinterUtil.isLocal(printername)); - } - - // - // Get details of a printer. - // - public synchronized void getPrinterDetails() - throws Exception - { - Debug.message("SVR: Printer.getPrinterDetails()"); - - if (printername == null) { - throw new pmInternalErrorException( - "Printer.getPrinterDetails(): printername must be set"); - } - DoPrinterView.view(this, nscontext); - } - - // - // Add a local printer - // - public synchronized void addLocalPrinter() - throws Exception - { - Debug.message("SVR: Printer.addLocalPrinter()"); - - if (printername == null) { - throw new pmInternalErrorException( - "Printer.addLocalPrinter(): printername must be set"); - } - if (printserver == null) { - Host h = new Host(); - printserver = h.getLocalHostName(); - h = null; - } - if (device == null) { - throw new pmInternalErrorException( - "Printer.addLocalPrinter(): device must be set"); - } - if ((pmMisc.isppdCachefile()) && use_ppd_file) { - if (make == null) { - throw new pmInternalErrorException( - "Printer.addLocalPrinter(): make must be set"); - } - if (model == null) { - throw new pmInternalErrorException( - "Printer.addLocalPrinter(): model must be set"); - } - if (ppd == null) { - throw new pmInternalErrorException( - "Printer.addLocalPrinter(): ppd file must be selected"); - } - } - - - PrinterDebug.printObj(this); - - clearLogs(); - DoPrinterAdd.add(this, nscontext); - } - - // - // Add access to a remote printer - // - public synchronized void addRemotePrinter() - throws Exception - { - Debug.message("SVR: Printer.addRemotePrinter()"); - - if (printername == null) { - throw new pmInternalErrorException( - "Printer.addRemotePrinter(): printername must be set"); - } - if (printserver == null) { - throw new pmInternalErrorException( - "Printer.addRemotePrinter(): printserver must be set"); - } - PrinterDebug.printObj(this); - - clearLogs(); - DoPrinterAdd.add(this, nscontext); - } - - // - // Delete a printer - // - public synchronized void deletePrinter() - throws Exception - { - Debug.message("SVR: Printer.deletePrinter()"); - - if (printername == null) { - throw new pmInternalErrorException( - "Printer.deletePrinter(): printername must be set"); - } - PrinterDebug.printObj(this); - - clearLogs(); - DoPrinterDelete.delete(this, nscontext); - } - - // - // Modify a printer - // - public synchronized void modifyPrinter() - throws Exception - { - Debug.message("SVR: Printer.modifyPrinter()"); - - if (printername == null) { - throw new pmInternalErrorException( - "Printer.modifyPrinter(): printername must be set"); - } - PrinterDebug.printObj(this); - - clearLogs(); - DoPrinterMod.modify(this, nscontext); - } - - // - // Set list of commands executed - // - public synchronized void setCmdLog(String newcmds) - { - if (newcmds == null) { - return; - } - if (!newcmds.endsWith("\n")) { - newcmds = newcmds.concat("\n"); - } - if (cmdlog == null) { - cmdlog = new String(newcmds); - return; - } - cmdlog = cmdlog.concat(newcmds); - } - - // - // Set an error message. - // - public synchronized void setErrorLog(String errs) - { - if (errs == null) { - return; - } - if (!errs.endsWith("\n")) { - errs = errs.concat("\n"); - } - if (errlog == null) { - errlog = new String(errs); - return; - } else { - errlog = errlog.concat(errs); - } - } - - // - // Set an warning message. - // - public synchronized void setWarnLog(String warning) - { - if (warning == null) { - return; - } - if (!warning.endsWith("\n")) { - warning = warning.concat("\n"); - } - if (warnlog == null) { - warnlog = new String(warning); - return; - } else { - warnlog = warnlog.concat(warning); - } - } - - // - // Get commands executed. - // - public String getCmdLog() - { - if (cmdlog == null) { - return (null); - } - return (new String(cmdlog.trim())); - } - - // - // Get error messages - // - public String getErrorLog() - { - if (errlog == null) { - return (null); - } - return (new String(errlog.trim())); - } - - // - // Get warning messages - // - public String getWarnLog() - { - if (warnlog == null) { - return (null); - } - return (new String(warnlog.trim())); - } - - // - // Set printer attributes - // - public synchronized void setPrinterName(String arg) - { - printername = arg; - } - public synchronized void setPrinterType(String arg) - { - printertype = arg; - } - public synchronized void setPrintServer(String arg) - { - printserver = arg; - } - public synchronized void setComment(String arg) - { - comment = arg; - } - public synchronized void setMake(String arg) - { - make = arg; - } - public synchronized void setModel(String arg) - { - model = arg; - } - public synchronized void setPPD(String arg) - { - ppd = arg; - } - public synchronized void setPPDFile(String arg) - { - ppdfile = arg; - } - public synchronized void setDevice(String arg) - { - device = arg; - } - public synchronized void setUsePPD(boolean arg) - { - use_ppd_file = arg; - } - public synchronized void setNotify(String arg) - { - notify = arg; - } - public synchronized void setProtocol(String arg) - { - protocol = arg; - } - public synchronized void setDestination(String arg) - { - destination = arg; - } - public synchronized void setExtensions(String arg) - { - extensions = arg; - } - public synchronized void setFileContents(String[] arg) - { - file_contents = arg; - } - public synchronized void setUserAllowList(String[] arg) - { - user_allow_list = arg; - } - public synchronized void setUserDenyList(String[] arg) - { - user_deny_list = arg; - } - public synchronized void setIsDefaultPrinter(boolean arg) - { - default_printer = arg; - } - public synchronized void setBanner(String arg) - { - banner = arg; - } - public synchronized void setEnable(boolean arg) - { - enable = arg; - } - public synchronized void setAccept(boolean arg) - { - accept = arg; - } - public synchronized void setLocale(String arg) - { - locale = arg; - } - - // - // Get printer attributes. - // - public String getPrinterName() - { - return (printername); - } - public String getPrinterType() - { - return (printertype); - } - public String getPrintServer() - { - return (printserver); - } - public String getComment() - { - return (comment); - } - public String getDevice() - { - return (device); - } - public boolean getUsePPD() - { - return (use_ppd_file); - } - public String getMake() - { - return (make); - } - public String getModel() - { - return (model); - } - public String getPPD() - { - return (ppd); - } - public String getPPDFile() - { - return (ppdfile); - } - public String getNotify() - { - return (notify); - } - public String getProtocol() - { - return (protocol); - } - public String getDestination() - { - return (destination); - } - public String getExtensions() - { - return (extensions); - } - public String[] getFileContents() - { - return (file_contents); - } - public String[] getUserAllowList() - { - return (user_allow_list); - } - public String[] getUserDenyList() - { - return (user_deny_list); - } - public boolean getIsDefaultPrinter() - { - return (default_printer); - } - public String getBanner() - { - return (banner); - } - public boolean getEnable() - { - return (enable); - } - public boolean getAccept() - { - return (accept); - } - public String getLocale() - { - return (locale); - } - - protected void clearLogs() - { - warnlog = null; - errlog = null; - cmdlog = null; - } - - // Hints for optimizing printer modifications - protected String modhints = ""; -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/PrinterDebug.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/PrinterDebug.java deleted file mode 100644 index 1997111b1c..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/PrinterDebug.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * PrinterDebug class - * Helper class to print attributes in objects. - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -public class PrinterDebug { - - public static void printObj(Printer p) - { - String arr[]; - int i; - - Debug.message("SVR: PrinterDebug.print_obj(Printer)"); - - Debug.message("SVR: \tName:\t\t" + p.getPrinterName()); - Debug.message("SVR: \tType:\t\t" + p.getPrinterType()); - Debug.message("SVR: \tServer:\t\t" + p.getPrintServer()); - Debug.message("SVR: \tComment:\t" + p.getComment()); - Debug.message("SVR: \tDevice:\t\t" + p.getDevice()); - Debug.message("SVR: \tMake:\t\t" + p.getMake()); - Debug.message("SVR: \tModel:\t\t" + p.getModel()); - Debug.message("SVR: \tPPD:\t\t" + p.getPPD()); - Debug.message("SVR: \tNotify:\t\t" + p.getNotify()); - Debug.message("SVR: \tProtocol:\t" + p.getProtocol()); - Debug.message("SVR: \tDest:\t\t" + p.getDestination()); - Debug.message("SVR: \tExtensions:\t" + p.getExtensions()); - Debug.message("SVR: \tDefault:\t" + p.getIsDefaultPrinter()); - Debug.message("SVR: \tBanner:\t\t" + p.getBanner()); - Debug.message("SVR: \tEnable:\t\t" + p.getEnable()); - Debug.message("SVR: \tAccept:\t\t" + p.getAccept()); - - arr = p.getFileContents(); - if (arr == null) { - Debug.message("SVR: \tContents:\tNULL"); - } else { - Debug.message("SVR: \tContents:"); - for (i = 0; i < arr.length; i++) { - Debug.message("SVR: \t\t\t" + arr[i]); - } - } - arr = p.getUserAllowList(); - if (arr == null) { - Debug.message("SVR: \tUser allow:\tNULL"); - } else { - Debug.message("SVR: \tUser allow:"); - for (i = 0; i < arr.length; i++) { - Debug.message("SVR: \t\t\t" + arr[i]); - } - } - arr = p.getUserDenyList(); - if (arr == null) { - Debug.message("SVR: \tUser deny:\tNULL"); - } else { - Debug.message("SVR: \tUser deny:"); - for (i = 0; i < arr.length; i++) { - Debug.message("SVR: \t\t\t" + arr[i]); - } - } - } - - public static void printObj(NameService ns) - { - Debug.message("SVR: PrinterDebug.printObj(NameService)"); - - // Keep passwd secret. - String passwd = ns.getPasswd(); - if (passwd != null) { - passwd = "*****"; - } - Debug.message("SVR: \tnameservice:\t" + ns.getNameService()); - Debug.message("SVR: \tnshost:\t\t" + ns.getNameServiceHost()); - Debug.message("SVR: \tuser:\t\t" + ns.getUser()); - Debug.message("SVR: \tpasswd:\t\t" + passwd); - Debug.message("SVR: \tboundtonisslave:" + ns.getBoundToNisSlave()); - Debug.message("SVR: \tisAuth:\t\t" + ns.isAuth()); - } - - public static String arr_to_str(String[] arr) - { - if (arr == null) { - return (new String("NULL")); - } - if (arr.length == 0) { - return (new String("0 length array")); - } - String str = ""; - for (int i = 0; i < arr.length; i++) { - if (arr[i] == null) { - break; - } - str = str.concat(arr[i] + " "); - } - return (str); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/PrinterUtil.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/PrinterUtil.java deleted file mode 100644 index ff5e947dcf..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/PrinterUtil.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * PrinterUtil class - * Methods not associated with a printer instance. - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -public class PrinterUtil { - - // - // main for testing - // - public static void main(String[] args) { - String dp = null; - String devs[] = null; - String printers[] = null; - - try { - NameService ns = new NameService("ldap"); -// checkRootPasswd("xxx"); - dp = getDefaultPrinter(ns); - devs = getDeviceList(); - printers = getPrinterList(ns); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - System.out.println("Default printer is: " + dp); - for (int i = 0; i < devs.length; i++) { - System.out.println(devs[i]); - } - for (int i = 0; i < printers.length; i += 3) { - System.out.println("printername: " + printers[i]); - System.out.println("servername: " + printers[i+1]); - System.out.println("comment: " + printers[i+2]); - } - System.exit(0); - } - - // - // Get the default printer for a specified name space - // - public synchronized static String getDefaultPrinter( - NameService ns) throws Exception - { - Debug.message("SVR: PrinterUtil.getDefaultPrinter()"); - - String nsarg = ns.getNameService(); - String ret = DoPrinterUtil.getDefault(nsarg); - if (ret == null) { - return (new String("")); - } - return (new String(ret)); - } - - // - // Get a list of possible printer devices for this machine. - // - public synchronized static String[] getDeviceList() throws Exception - { - Debug.message("SVR: PrinterUtil.getDeviceList()"); - - String emptylist[] = new String[1]; - emptylist[0] = ""; - - String ret[] = DoPrinterUtil.getDevices(); - if (ret == null) { - return (emptylist); - } - return (ret); - } - - // - // Get the list of supported Printer Makes (Manufacturers) - // If supported, a PPD file exists for this Make - // - public synchronized static String[] getMakesList() throws Exception - { - Debug.message("SVR: PrinterUtil.getMakesList()"); - - String emptylist[] = new String[1]; - emptylist[0] = ""; - - String ret[] = DoPrinterUtil.getMakes(); - if (ret == null) { - return (emptylist); - } - return (ret); - } - - public synchronized static String[] getModelsList( - String make) throws Exception - - { - Debug.message("SVR: PrinterUtil.getModelsList()"); - - String emptylist[] = new String[1]; - emptylist[0] = ""; - - String ret[] = DoPrinterUtil.getModels(make); - return (ret); - } - - public synchronized static String[] getPPDList( - String make, String model) throws Exception - - { - Debug.message("SVR: PrinterUtil.getPPDList()"); - - String emptylist[] = new String[1]; - emptylist[0] = ""; - - String ret[] = DoPrinterUtil.getPPDs(make, model); - if (ret == null) { - return (emptylist); - } - return (ret); - } - - public synchronized static String[] getProbePrinter(String device) - { - Debug.message("SVR: PrinterUtil.getProbePrinter()"); - - String ret[] = DoPrinterUtil.getProbe(device); - return (ret); - } - - - // - // Get a list of printers in the specified name service. - // - public synchronized static String[] getPrinterList( - NameService ns) throws Exception - { - Debug.message("SVR: PrinterUtil.getPrinterList()"); - - String emptylist[] = new String[1]; - emptylist[0] = ""; - - String nsarg = ns.getNameService(); - String[] ret = DoPrinterUtil.getList(nsarg); - if (ret == null) { - return (emptylist); - } - return (ret); - } - - // - // Does this printer already exist in the specified - // name service - // - public synchronized static boolean exists( - String name, - NameService ns) throws Exception - { - Debug.message("SVR: PrinterUtil.exists()"); - - String nsname = ns.getNameService(); - return (DoPrinterUtil.exists(name, nsname)); - } - - public synchronized static boolean isLocal( - String printername) throws Exception - { - Debug.message("SVR: PrinterUtil.isLocal()"); - - return (DoPrinterUtil.isLocal(printername)); - } - - public synchronized static void checkRootPasswd( - String passwd) throws Exception - { - DoPrinterNS.doCheckRootPasswd(passwd); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/SysCommand.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/SysCommand.java deleted file mode 100644 index cd8afb1364..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/SysCommand.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * SysCommand - * Execute a command and capture stdout/stderr. - * - */ - -package com.sun.admin.pm.server; - -import java.io.*; - -public class SysCommand -{ - - private Process p = null; - private String out = null; - private String err = null; - private int status = 0; - - public static void main(String[] args) { - SysCommand syscmd = new SysCommand(); - String cmd = "ypcat hosts"; - String o = ""; - try { - syscmd.exec(cmd); - } - catch (Exception e) { - System.out.println(e); - } - o = syscmd.getOutput(); - System.out.println(o); - } - - /* - * Execute a system command. - * @param String cmd The command to be executed. - */ - public void exec(String cmd) throws Exception - { - if (cmd == null) { - throw new pmInternalErrorException( - "SysCommand.exec(): null command"); - } - - debug_log(cmd); - - p = Runtime.getRuntime().exec(cmd); - if (p == null) { - throw new pmInternalErrorException( - "SysCommand.exec(): null process"); - } - out = readOut(); - err = readErr(); - p.waitFor(); - status = getStatus(); - dispose(); - } - - public void exec(String[] cmd) throws Exception - { - if (cmd == null) { - throw new pmInternalErrorException( - "SysCommand.exec(): null command"); - } - - // Trim command arrays with nulls at the end. - int i; - for (i = 0; i < cmd.length; i++) { - if (cmd[i] == null) { - break; - } - } - if (i != cmd.length) { - String[] newcmd = new String[i]; - - for (i = 0; i < newcmd.length; i++) { - newcmd[i] = cmd[i]; - } - debug_log(PrinterDebug.arr_to_str(newcmd)); - p = Runtime.getRuntime().exec(newcmd); - } else { - debug_log(PrinterDebug.arr_to_str(cmd)); - p = Runtime.getRuntime().exec(cmd); - } - if (p == null) { - throw new pmInternalErrorException( - "SysCommand.exec(): null process"); - } - out = readOut(); - err = readErr(); - p.waitFor(); - status = getStatus(); - dispose(); - } - - - public void exec(String cmd, String locale) throws Exception - { - if (cmd == null) { - throw new pmInternalErrorException( - "SysCommand.exec(): null command"); - } - - debug_log(locale + "; " + cmd); - - String [] envp = new String[1]; - envp[0] = locale; - p = Runtime.getRuntime().exec(cmd, envp); - if (p == null) { - throw new pmInternalErrorException( - "SysCommand.exec(): null process"); - } - out = readOut(); - err = readErr(); - p.waitFor(); - status = getStatus(); - dispose(); - } - - public String getOutput() { - if (out == null) - return (null); - return (new String(out)); - } - public String getError() { - if (err == null) - return (null); - return (new String(err)); - } - public int getExitValue() { - return (status); - } - - - private String readOut() throws Exception - { - String result = null; - String line = null; - BufferedReader out = null; - - out = new BufferedReader( - new InputStreamReader(p.getInputStream())); - while ((line = out.readLine()) != null) { - if (result == null) - result = line; - else - result = result.concat("\n" + line); - } - return (result); - } - - private String readErr() throws Exception - { - String errstr = null; - String line = null; - BufferedReader err = null; - - err = new BufferedReader( - new InputStreamReader(p.getErrorStream())); - while ((line = err.readLine()) != null) { - if (errstr == null) { - errstr = line; - } else { - errstr = errstr.concat("\n" + line); - } - } - return (errstr); - } - - private int getStatus() throws Exception - { - return (p.exitValue()); - } - - /* - * Clean up opened file descriptors. - */ - private void dispose() { - - try { - p.getInputStream().close(); - p.getOutputStream().close(); - p.getErrorStream().close(); - p.destroy(); - } - catch (Exception e) { - Debug.message("SVR:" + e.getMessage()); - } - } - - /* - * Log all commands as is except lpset with a password. - */ - private void debug_log(String cmd) - { - if ((cmd.indexOf("lpset") != -1) && - (cmd.indexOf(" -w ") != -1)) { - String clean = ""; - int i = cmd.indexOf(" -w "); - int j = 0; - - try { - i += 4; - clean = cmd.substring(0, i); - clean = clean.concat("**** "); - while (cmd.charAt(i) != ' ') { - i++; - } - } catch (Exception e) { - Debug.message("SVR: lpset command with a passwd."); - return; - } - - clean = clean.concat(cmd.substring(i, cmd.length())); - Debug.message("SVR: " + clean); - - } else { - Debug.message("SVR: " + cmd); - } - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Test.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Test.java deleted file mode 100644 index 31e9339f10..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Test.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Test - * Command line front end to Printer class - * - * Takes one argument - the name of a test file - * The format of the file is: - * Required: - * action=[add,delete,modify,view,list] - * - * Optional: - * printername= - * printertype= - * printserver= - * comment= - * device= - * notify= - * protocol= - * destination= - * extensions= - * default_printer=[true,false] - * banner= - * enable=[true,false] - * accept=[true,false] - * file_contents=[space seperated list] - * user_allow_list=[space seperated list] - * user_deny_list=[space seperated list] - * nameservice=[system,nis] - * nshost= - * user= - * passwd= - * locale= - * - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -public class Test { - public static void main(String[] args) { - String tmpstr; - int i; - String testfile = ""; - if (args.length == 1) { - testfile = args[0]; - } else { - System.out.println("Usage: Test testfile"); - System.exit(1); - } - - String cmd = "/usr/bin/cat " + testfile; - String o = null; - try { - SysCommand syscmd = new SysCommand(); - syscmd.exec(cmd); - if (syscmd.getExitValue() != 0) { - System.out.println("Problem opening test file"); - System.exit(1); - } - o = syscmd.getOutput(); - syscmd = null; - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - o = o.concat("\n"); - - String action = getToken(o, "action="); - String printername = getToken(o, "printername="); - String printertype = getToken(o, "printertype="); - String printserver = getToken(o, "printserver="); - String comment = getToken(o, "comment="); - String device = getToken(o, "device="); - String notify = getToken(o, "notify="); - String banner = getToken(o, "banner="); - String protocol = getToken(o, "protocol="); - String destination = getToken(o, "destination="); - String extensions = getToken(o, "extensions="); - - String[] file_contents = null; - String[] user_allow_list = null; - String[] user_deny_list = null; - - StringTokenizer st; - tmpstr = getToken(o, "file_contents="); - if (tmpstr != null) { - st = new StringTokenizer(tmpstr); - if (st.countTokens() != 0) { - file_contents = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - file_contents[i] = st.nextToken(); - } - } - } - tmpstr = getToken(o, "user_allow_list="); - if (tmpstr != null) { - st = new StringTokenizer(tmpstr); - if (st.countTokens() != 0) { - user_allow_list = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - user_allow_list[i] = st.nextToken(); - } - } - } - tmpstr = getToken(o, "user_deny_list="); - if (tmpstr != null) { - st = new StringTokenizer(tmpstr); - if (st.countTokens() != 0) { - user_deny_list = new String[st.countTokens()]; - for (i = 0; st.hasMoreTokens(); i++) { - user_deny_list[i] = st.nextToken(); - } - } - } - - boolean default_printer = false; - boolean enable = false; - boolean accept = false; - - tmpstr = getToken(o, "default_printer="); - if (tmpstr != null) { - if (tmpstr.equals("true")) { - default_printer = true; - } - } - tmpstr = getToken(o, "enable="); - if (tmpstr != null) { - if (tmpstr.equals("true")) { - enable = true; - } - } - tmpstr = getToken(o, "accept="); - if (tmpstr != null) { - if (tmpstr.equals("true")) { - accept = true; - } - } - - String nameservice = getToken(o, "nameservice="); - String nshost = getToken(o, "nshost="); - String user = getToken(o, "user="); - String passwd = getToken(o, "passwd="); - String locale = getToken(o, "locale="); - - // - // Done parsing. Let's do the work. - // - Debug.setDebugLevel(Debug.ALL); - - NameService ns = null; - try { - ns = new NameService(nameservice); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - if (nameservice.equals("nis") || nameservice.equals("ldap")) { - if (nshost != null) - ns.setNameServiceHost(nshost); - if (user != null) - ns.setUser(user); - if (passwd != null) - ns.setPasswd(passwd); - } - try { - ns.checkAuth(); - } - catch (Exception e) { - System.out.println(e); - } - - Printer p = new Printer(ns); - - p.setPrinterName(printername); - p.setPrinterType(printertype); - p.setPrintServer(printserver); - p.setFileContents(file_contents); - p.setComment(comment); - p.setDevice(device); - p.setNotify(notify); - p.setProtocol(protocol); - p.setDestination(destination); - p.setIsDefaultPrinter(default_printer); - p.setBanner(banner); - p.setEnable(enable); - p.setAccept(accept); - p.setUserAllowList(user_allow_list); - p.setUserDenyList(user_deny_list); - p.setLocale(locale); - - if (action.equals("list")) { - String[] plist = null; - try { - plist = PrinterUtil.getPrinterList(ns); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - if (plist == null) { - System.out.println("No printers"); - } else { - printPList(plist); - } - } else if (action.equals("view")) { - try { - p.getPrinterDetails(); - } - catch (Exception e) - { - System.out.println(e); - } - printView(p); - } else if (action.equals("add")) { - try { - if (device == null) { - p.addRemotePrinter(); - } else { - p.addLocalPrinter(); - } - } - catch (Exception e) - { - System.out.println(e); - } - } else if (action.equals("modify")) { - try { - p.modifyPrinter(); - } - catch (Exception e) - { - System.out.println(e); - } - } else if (action.equals("delete")) { - try { - p.deletePrinter(); - } - catch (Exception e) - { - System.out.println(e); - } - } else { - System.out.println("unknown action"); - System.exit(1); - } - System.out.println("============================"); - System.out.println("Commands:\n" + p.getCmdLog()); - System.out.println("Errors:\n" + p.getErrorLog()); - System.out.println("Warnings:\n" + p.getWarnLog()); - System.exit(0); - } - - private static String getToken(String str, String sub) - { - int i = -1; - int j = -1; - String result = null; - - i = str.indexOf(sub); - if (i != -1) { - i = i + sub.length(); - j = str.indexOf("\n", i); - if (j != -1) { - result = str.substring(i, j); - result = result.trim(); - if (result.equals("")) - result = null; - } - } - return (result); - } - - private static void printPList(String[] list) - { - if (list == null) - return; - if (list[0].equals("")) { - System.out.println("No printers found"); - return; - } - - for (int i = 0; i < list.length; ) { - System.out.println("name: " + list[i++]); - System.out.println("server: " + list[i++]); - System.out.println("comment: " + list[i++]); - } - } - - private static void printView(Printer p) - { - String arr[]; - int i; - - System.out.println("Name: " + p.getPrinterName()); - System.out.println("Type: " + p.getPrinterType()); - System.out.println("Server: " + p.getPrintServer()); - System.out.println("Comment: " + p.getComment()); - System.out.println("Device: " + p.getDevice()); - System.out.println("Notify: " + p.getNotify()); - System.out.println("Protocol: " + p.getProtocol()); - System.out.println("Dest: " + p.getDestination()); - System.out.println("Extensions: " + p.getExtensions()); - System.out.println("Default: " + p.getIsDefaultPrinter()); - System.out.println("Banner: " + p.getBanner()); - System.out.println("Enable: " + p.getEnable()); - System.out.println("Accept: " + p.getAccept()); - - arr = p.getFileContents(); - if (arr == null) { - System.out.println("Contents: NULL"); - } else { - System.out.println("Contents:"); - for (i = 0; i < arr.length; i++) { - System.out.println("\t\t" + arr[i]); - } - } - arr = p.getUserAllowList(); - if (arr == null) { - System.out.println("Users allow: NULL"); - } else { - System.out.println("Users allow:"); - for (i = 0; i < arr.length; i++) { - System.out.println("\t\t" + arr[i]); - } - } - arr = p.getUserDenyList(); - if (arr == null) { - System.out.println("Users deny: NULL"); - } else { - System.out.println("Users deny:"); - for (i = 0; i < arr.length; i++) { - System.out.println("\t\t" + arr[i]); - } - } - - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Valid.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Valid.java deleted file mode 100644 index a457be1e58..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Valid.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Valid - * Check user input. We are mostly concerned with characters - * we know will cause problems for the sub-system. - * multi-byte characters will be screened out by the gui. - */ - -package com.sun.admin.pm.server; - -import java.io.*; -import java.util.*; - -public class Valid { - - static String spaces = "\t "; - /* JSTYLED */ - static String badmetas = "\"\\$^&*(){}`'|;:?<>"; - /* JSTYLED */ - static String baddestmetas = "\"\\$^&*(){}`'|;?<>"; - - // lpadmin used to only take 14. - static int validlocalprinternamelength = 1024; - // MAXHOSTNAMELEN + MAXPATHLEN seems reasonable. - static int validremoteprinternamelength = 1280; - - static int validdestinationlength = 1023; // BUFSIZ-1 seems generous - static int validcommentlength = 256; // From admintool - static int validservernamelength = 256; // MAXHOSTNAMELEN = 256 - static int validusernamelength = 128; // LOGNAME_MAX = 8 but since - // it's not enforced ... - static int validmakelength = 256; // MAXNAMELEN = 256 - - // - // main for testing - // - public static void main(String[] args) { - String[] users_arr = { "one", "two", "th`ee" }; - try { - System.out.println(localPrinterName("foo/bar")); - System.out.println(comment("abad:comment")); - System.out.println(device("/dev/term/a")); - System.out.println(printerType(" ")); - System.out.println(serverName(",bad")); - System.out.println(users(users_arr)); - } - catch (Exception e) - { - System.out.println(e); - System.exit(1); - } - System.exit(0); - } - - // - // Valid comment - // - public static boolean comment(String cstr) - { - Debug.message("SVR: Valid.comment()"); - Debug.message("SVR: comment=" + cstr); - - if (cstr == null) - return (false); - if (cstr.length() > validcommentlength) - return (false); - - String c = cstr.substring(0, 1); - // Causes problems in lpadmin - if (c.equals(",")) { - return (false); - } - if (c.equals("-")) { - return (false); - } - - return (validString(cstr, badmetas + "=")); - } - - // - // Valid local printer name - // - public static boolean localPrinterName(String pn) - { - Debug.message("SVR: Valid.localPrinterName()"); - Debug.message("SVR: printerName=" + pn); - - if (pn == null) - return (false); - if (pn.length() == 0) - return (false); - if (pn.length() > validlocalprinternamelength) - return (false); - - String c = pn.substring(0, 1); - if (c.equals(".")) { - return (false); - } - if (c.equals("!")) { - return (false); - } - if (c.equals("=")) { - return (false); - } - - // Keywords for the sub-system - if (pn.equals("_default")) - return (false); - if (pn.equals("_all")) - return (false); - - return (validString(pn, badmetas + spaces + "/#:,")); - } - - // - // Valid remote printer name - // - public static boolean remotePrinterName(String pn) - { - Debug.message("SVR: Valid.remotePrinterName()"); - Debug.message("SVR: printerName=" + pn); - - if (pn == null) - return (false); - if (pn.length() == 0) - return (false); - if (pn.length() > validremoteprinternamelength) - return (false); - - // Keywords for the sub-system - if (pn.equals("_default")) - return (false); - if (pn.equals("_all")) - return (false); - - String c = pn.substring(0, 1); - if (c.equals(".")) { - return (false); - } - if (c.equals("!")) { - return (false); - } - if (c.equals("=")) { - return (false); - } - - return (validString(pn, badmetas + spaces + "/#:,")); - } - - // - // Valid device - // Does it exist and is it writable. - // - public static boolean device(String dev) - throws Exception - { - int exitvalue; - - Debug.message("SVR: Valid.device()"); - Debug.message("SVR: device=" + dev); - - if (dev == null) - return (false); - if (dev.length() == 0) - return (false); - if (dev.indexOf("://") != 0) // don't test if it's a URI - return (true); - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/test -w " + dev); - exitvalue = syscmd.getExitValue(); - syscmd = null; - - if (exitvalue != 0) - return (false); - return (true); - } - - // - // Valid Printer Make - // Does a directory of that name exist, and is it readable. - // - - public static boolean make(String dir) - throws Exception - { - int exitvalue; - - Debug.message("SVR: Valid.make()"); - Debug.message("SVR: dir=" + dir); - - if (dir == null) - return (false); - if ((dir.length() == 0) || (dir.length() > validmakelength)) - return (false); - - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/test -d -r " + dir); - exitvalue = syscmd.getExitValue(); - syscmd = null; - - if (exitvalue != 0) - return (false); - return (true); - } - - // - // Valid printer type - // - public static boolean printerType(String pt) - throws Exception - { - int exitvalue; - - Debug.message("SVR: Valid.printerType()"); - Debug.message("SVR: printerType=" + pt); - - if (pt == null) - return (false); - if (pt.length() == 0) - return (false); - - if (pt.equals("/")) - return (false); - - if (pt.indexOf(" ") != -1) { - return (false); - } - if (pt.indexOf("\t") != -1) { - return (false); - } - - String c = pt.substring(0, 1); - String path = "/usr/share/lib/terminfo/" + c + "/" + pt; - SysCommand syscmd = new SysCommand(); - syscmd.exec("/usr/bin/test -r " + path); - exitvalue = syscmd.getExitValue(); - syscmd = null; - - if (exitvalue != 0) - return (false); - return (true); - } - - // - // Valid destination - // - public static boolean destination(String d) - { - Debug.message("SVR: Valid.destination()"); - Debug.message("SVR: destination=" + d); - - if (d == null) - return (false); - if (d.length() == 0) - return (false); - if (d.length() > validdestinationlength) - return (false); - - return (validString(d, baddestmetas + spaces)); - } - - // - // Valid Server name - // - public static boolean serverName(String s) - { - Debug.message("SVR: Valid.serverName()"); - Debug.message("SVR: serverName=" + s); - - if (s == null) - return (false); - if (s.length() == 0) - return (false); - if (s.length() > validservernamelength) - return (false); - - String c = s.substring(0, 1); - if (c.equals("!")) { - return (false); - } - if (c.equals("=")) { - return (false); - } - - return (validString(s, badmetas + spaces + "#,:")); - } - - // - // Users - // - public static boolean users(String[] u) - { - Debug.message("SVR: Valid.users()"); - Debug.message("SVR: users = " + PrinterDebug.arr_to_str(u)); - - if (u == null) { - return (false); - } - if (u.length == 0) { - return (false); - } - - for (int i = 0; i < u.length; i++) { - if (u[i] == null) { - return (false); - } - if (u[i].length() == 0) { - return (false); - } - if (u[i].length() > validusernamelength) { - return (false); - } - if (!validString(u[i], badmetas + spaces)) { - return (false); - } - } - return (true); - } - - // - // User - // - public static boolean user(String u) - { - Debug.message("SVR: Valid.users()"); - Debug.message("SVR: users = " + u); - - if (u == null) { - return (false); - } - if (u.length() == 0) { - return (false); - } - - if (u == null) { - return (false); - } - if (u.length() == 0) { - return (false); - } - if (u.length() > validusernamelength) { - return (false); - } - if (!validString(u, badmetas + spaces)) { - return (false); - } - return (true); - } - - - // - // Check to see if a string contains an invalid character - // - private static boolean validString(String str, String badchars) - { - // Can't start with a hyphen - String start = str.substring(0, 1); - if (start.equals("-")) - return (false); - - char[] badchars_arr = badchars.toCharArray(); - - for (int i = 0; i < badchars_arr.length; i++) { - if (str.indexOf(badchars_arr[i]) != -1) { - return (false); - } - } - return (true); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmAuthException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmAuthException.java deleted file mode 100644 index 3c24fa53d2..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmAuthException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmAuthException class - * User is not authorized to perform an operation. - */ - -package com.sun.admin.pm.server; - -public class pmAuthException extends pmException -{ - public pmAuthException() - { - super(); - } - - public pmAuthException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmAuthRhostException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmAuthRhostException.java deleted file mode 100644 index 2f6b41e5f3..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmAuthRhostException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmAuthRhostException class - * A .rhosts entry has not been set up allowing updates of - * pre-2.6 nis servers. - * - */ - -package com.sun.admin.pm.server; - -public class pmAuthRhostException extends pmAuthException -{ - public pmAuthRhostException() - { - super(); - } - - public pmAuthRhostException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmCmdFailedException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmCmdFailedException.java deleted file mode 100644 index 26925a1d97..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmCmdFailedException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmCmdFailedException class - * A command unexpectedly failed. - */ - -package com.sun.admin.pm.server; - -public class pmCmdFailedException extends pmException -{ - public pmCmdFailedException() - { - super(); - } - - public pmCmdFailedException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmException.java deleted file mode 100644 index 081c27e79e..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmException class - * General print manager exceptions - */ - -package com.sun.admin.pm.server; - -public class pmException extends Exception -{ - public pmException() - { - super(); - } - - public pmException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmHostNotPingableException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmHostNotPingableException.java deleted file mode 100644 index cc8464a17b..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmHostNotPingableException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmHostNotPingableException class - * A host is not accessible using ping. - */ - -package com.sun.admin.pm.server; - -public class pmHostNotPingableException extends pmException -{ - public pmHostNotPingableException() - { - super(); - } - - public pmHostNotPingableException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmInternalErrorException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmInternalErrorException.java deleted file mode 100644 index 08f50dbc8f..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmInternalErrorException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmInternalErrorException class - * An internal error has occuured. This is often associated - * with the server not getting enough information to perform - * an action. - */ - -package com.sun.admin.pm.server; - -public class pmInternalErrorException extends pmException -{ - public pmInternalErrorException() - { - super(); - } - - public pmInternalErrorException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmMisc.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmMisc.java deleted file mode 100644 index 21202c0eba..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmMisc.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Miscellaneous functions which don't apply to printer object - */ - -package com.sun.admin.pm.server; - -import java.io.*; - -/* - * Class is miscellaneous routines - */ - -public class pmMisc { - - public static boolean isppdCachefile() - { - File ppdcache = new File("/var/lp/ppd/ppdcache"); - return (ppdcache.isFile()); - } - -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmNSNotConfiguredException.java b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmNSNotConfiguredException.java deleted file mode 100644 index 1ffd8ccd50..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmNSNotConfiguredException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - * - * pmNSNotConfiguredException class - * The selected name service does not appear to be configured - * on the host. - */ - -package com.sun.admin.pm.server; - -public class pmNSNotConfiguredException extends pmException -{ - public pmNSNotConfiguredException() - { - super(); - } - - public pmNSNotConfiguredException(String s) - { - super(s); - } -} diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmtest b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmtest deleted file mode 100644 index 70a7770530..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/pmtest +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 1999 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" - -/usr/bin/java com.sun.admin.pm.server.Test $1 diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/tests/template b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/tests/template deleted file mode 100644 index 4096d9bae5..0000000000 --- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/tests/template +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#pragma ident "%Z%%M% %I% %E% SMI" - -action= -printername= -printertype= -printserver= -file_contents= -comment= -device= -notify= -protocol= -destination= -default_printer= -banner= -enable= -accept= -user_allow_list= -user_deny_list= -nameservice= -nshost= -user= -passwd= -locale= diff --git a/usr/src/cmd/print/scripts/Makefile b/usr/src/cmd/print/scripts/Makefile deleted file mode 100644 index 7dfa94546e..0000000000 --- a/usr/src/cmd/print/scripts/Makefile +++ /dev/null @@ -1,149 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -include ../Makefile.sp - -ROOTPRINTLIB = $(ROOTLIB)/print -ROOTLIBLPBIN = $(ROOTLIBLP)/bin -ROOTVARLP = $(ROOTVAR)/lp -ROOTVARLPPPD = $(ROOTVARLP)/ppd - -$(ROOTVARLP) := DIRMODE=0775 - -FILEMODE = 0755 - -MSGFILES = lpadmin ppdmgr -POFILE = scripts.po - -PROG = conv_lp conv_lpd Makefile.yp -ROOTLIBPRINTPROG= $(PROG:%=$(ROOTPRINTLIB)/%) -$(ROOTLIBPRINTPROG) := FILEMODE=0555 -$(ROOTPRINTLIB)/Makefile.yp := FILEMODE=0444 - -USRSBINPROG= lpsystem ppdmgr -ROOTUSRSBINPROG= $(USRSBINPROG:%=$(ROOTUSRSBIN)/%) -$(ROOTUSRSBINPROG) := FILEMODE=555 - -PCONF= printers.conf -ROOTPCONF= $(PCONF:%=$(ROOTETC)/%) -$(ROOTPCONF) := FILEMODE=644 - -MANUFALIASES= manufaliases -ROOTMANUFALIASES= $(MANUFALIASES:%=$(ROOTVARLPPPD)/%) -$(ROOTMANUFALIASES) := FILEMODE=444 - -LIBLPPROGS= getmakes getmodels getppdfile getppds ppdfilename2mmp \ - lpadmin \ - desktop-print-management \ - desktop-print-management-applet \ - desktop-print-management-prefs - -ROOTLIBLPPROGS= $(LIBLPPROGS:%=$(ROOTLIBLPBIN)/%) -$(ROOTLIBLPPROGS) := FILEMODE=555 - -LIBLINKS= $(ROOTLIB)/lpadmin $(ROOTLIB)/lpsystem - -APPFILES = desktop-print-management.desktop -APPFILES += desktop-print-management-prefs.desktop -AUTOFILES = desktop-print-management-applet.desktop - -ROOTAPPDIR = $(ROOT)/usr/share/applications -ROOTAUTODIR = $(ROOT)/usr/share/gnome/autostart -ROOTAPPFILES = $(APPFILES:%=$(ROOTAPPDIR)/%) -ROOTAUTOFILES = $(AUTOFILES:%=$(ROOTAUTODIR)/%) - -$(ROOTAPPFILES) := FILEMODE = 444 -$(ROOTAUTOFILES) := FILEMODE = 444 - - -.KEEP_STATE: - -all : $(PROG) - -$(ROOTLIB)/print/%: % - $(INS.file) - -$(ROOTLIBLPBIN)/%: % - $(INS.file) - -$(ROOTVARLPPPD)/%: % - $(INS.file) - -$(ROOTAPPDIR)/%: % - $(INS.file) - -$(ROOTAUTODIR)/%: % - $(INS.file) - -$(ROOTUSRSBIN) $(ROOTVARSPOOLPRINT) $(ROOTVARLP) $(ROOTVARLPPPD): - $(INS.dir) - -$(ROOTLIB)/lpadmin: - $(RM) $@; $(SYMLINK) ../sbin/lpadmin $@ - -$(ROOTLIB)/lpsystem: - $(RM) $@; $(SYMLINK) ../sbin/lpsystem $@ - -$(ROOTLNKPROGS) : $(ROOTSTARTPROG) - $(RM) $@; $(LN) $(ROOTSTARTPROG) $@ - -_msg: $(POFILE) - -$(POFILE): $(MSGFILES) - grep gettext $(MSGFILES) | tr '`' ' ' | sed -e "s/gettext \"/gettext \(\"/" | sed -e "s/$$/);/" > $(POFILE).i - $(XGETTEXT) -s $(POFILE).i - $(RM) $@ $(POFILE).i - mv messages.po $(POFILE) - -# -# Create a message file to test with -# -_msg_test: - grep gettext $(MSGFILES) | tr '`' ' ' | sed -e "s/gettext \"/gettext \(\"/" | sed -e "s/$$/);/" > $(POFILE).i - $(XGETTEXT) -s -m "xxx" $(POFILE).i - $(RM) $@ $(POFILE).i - mv messages.po $(POFILE) - -install: $(ROOTLNKPROGS) \ - $(ROOTLIBPRINTPROG) $(ROOTSTARTPROG) \ - $(ROOTUSRSBIN) $(ROOTUSRSBINPROG) \ - $(ROOTVARSPOOLPRINT) $(ROOTPCONF) \ - $(ROOTLIBLPPROGS) $(LIBLINKS) \ - $(ROOTVARLP) $(ROOTVARLPPPD) \ - $(ROOTMANUFALIASES) \ - $(ROOTAPPFILES) $(ROOTAUTOFILES) - -$(SYMLINKS1): - $(RM) $@; $(SYMLINK) ../sbin/$(SBINPROG1) $@ - -$(SYMLINKS2): - $(RM) $@; $(SYMLINK) ../sbin/$(SBINPROG2) $@ - -clean: - $(RM) $(POFILE) - -clobber: clean - -strip lint: diff --git a/usr/src/cmd/print/scripts/Makefile.yp b/usr/src/cmd/print/scripts/Makefile.yp deleted file mode 100644 index 2e5647f4f1..0000000000 --- a/usr/src/cmd/print/scripts/Makefile.yp +++ /dev/null @@ -1,58 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyrights (c) 1996 by Sun Microsystems, Inc. -# All Rights Reserved -# -# Example pieces of NIS Makefile. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# -# Printers conf Rules -# -DIR=/etc -# -$(DOM)/printers.conf.time: $(DIR)/printers.conf - -@if [ -f $(DIR)/printers.conf ]; then \ - (sed -e '/^#/d' -e s/#.*$$// -e 's/[ ][ ]*$$//' \ - -e '/\\$$/s/\\$$/ /' $(DIR)/printers.conf $(CHKPIPE))\ - |( awk '/ $$/ {printf "%s", $$0} !/ $$/ {print}' $(CHKPIPE))\ - |( sed -e 's/[ ][ ]*/ /g' -e 's/:[ ]*:/:/' \ - $(CHKPIPE))\ - | awk -F: '{n=split($$1, nm, "|"); for (i=1; i<=n; i++) \ - print nm[i], $$0}' \ - | $(MAKEDBM) - $(YPDBDIR)/$(DOM)/printers.conf.byname ; \ - touch $(DOM)/printers.conf.time; \ - echo "updated printers.conf"; \ - if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) printers.conf.byname; \ - fi ; \ - if [ ! $(NOPUSH) ]; then echo "pushed printers.conf"; fi ; \ - else \ - echo "couldn't find $(DIR)/printers.conf"; \ - fi - -# -# Dependency -# -printers.conf: $(DOM)/printers.conf.time diff --git a/usr/src/cmd/print/scripts/conv_lp b/usr/src/cmd/print/scripts/conv_lp deleted file mode 100644 index 286ba6f682..0000000000 --- a/usr/src/cmd/print/scripts/conv_lp +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright (c) 1994, 1995, 1996 by Sun Microsystems, Inc. -# All Rights Reserved -# -# ident "%Z%%M% %I% %E% SMI" -# -# This script will automatically generate a "printcap" file -# from the currently configured LP printer configuration. -# -PATH=/bin:/usr/bin:/usr/sbin - -TEXTDOMAIN="SUNW_OST_OSCMD" -export TEXTDOMAIN - -export PATH -umask 022 - -set -- `getopt d:f: $*` -if [ $? != 0 ] ; then - echo "Usage: $0 [-d dir] [-f file]" - exit 1 -fi - -for OPTION in $* -do - case $OPTION in - -f) SYSTEM_FILE=$2; shift 2;; - -d) BASE_DIR=$2; shift 2;; - --) shift; break;; - esac -done - -SYSTEM_FILE=${SYSTEM_FILE:-"${BASE_DIR}/etc/printers.conf"} - -if [ ! -d ${BASE_DIR}/etc/lp/printers ] ; then - gettext "Exit $0: There is no directory ${BASE_DIR}/etc/lp/printers\n\tfrom which to create /etc/printers.conf." - exit 0 -fi - -if [ -f ${BASE_DIR}/etc/lp/default ] ; then - DEFAULT_PRINTER=`cat ${BASE_DIR}/etc/lp/default` - lpset -n system -a "use=${DEFAULT_PRINTER}" _default - mv ${BASE_DIR}/etc/lp/default ${BASE_DIR}/etc/default.orig -fi - -cd ${BASE_DIR}/etc/lp/printers # get the list of locally configured printers -PRINTERS=`echo *` - -for PRINTER in ${PRINTERS} # for each printer get config info -do - if [ "${PRINTER}" = "*" ] ; then - continue - fi - - RNAME=${PRINTER} - DESC="" - RHOST="" - - if [ -f ${PRINTER}/comment ] ; then - DESC=`cat ${PRINTER}/comment` - fi - - REMOTE=`grep Remote: ${PRINTER}/configuration 2>/dev/null | sed -e "s/^Remote: //"` - DEVICE=`grep Device: ${PRINTER}/configuration 2>/dev/null | sed -e "s/^Device: //"` - - if [ -n "${DEVICE}" ] ; then - RHOST=`uname -n` - elif [ `echo ${REMOTE} | grep -c \!` -ne 0 ] ; then - RHOST=`echo $REMOTE | cut -d \! -f 1` - RNAME=`echo $REMOTE | cut -d \! -f 2` - else - RHOST=${REMOTE} - fi - - lpset -n system -a "bsdaddr=${RHOST},${RNAME}" -a "description=${DESC}" \ - ${PRINTER} - -done - -exit 0 diff --git a/usr/src/cmd/print/scripts/conv_lpd b/usr/src/cmd/print/scripts/conv_lpd deleted file mode 100644 index e75d411ba8..0000000000 --- a/usr/src/cmd/print/scripts/conv_lpd +++ /dev/null @@ -1,213 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright (c) 1994, 1995, 1996 by Sun Microsystems, Inc. -# All Rights Reserved -# -# ident "%Z%%M% %I% %E% SMI" -# -# Printcap <-> Printers.conf conversion utility... -# -# Usage: conv_lpd [ -c (printers|printcap) ] [ -n ] (file) -# - -TEXTDOMAIN="SUNW_OST_OSCMD" -export TEXTDOMAIN - -USAGE=`gettext "Usage: conv_lpd [ -c (printers|printcap) ] [ -n ] (file)\n"` - -PATH=/usr/bin:/bin:/usr/sbin export PATH -conversion="printers" -namelist=0 - -umask 022 - -for i in $* -do - case $1 in - -c*) - conversion=$2; - shift ; shift ; - ;; - -n*) - namelist=1; - shift ; - ;; - *) - break ; - ;; - esac -done - -TMPF1=/tmp/tinput1.$$ -TMPF2=/tmp/tinput2.$$ -FILE=/tmp/input.$$ - -# Any remaining arg is the "file" specification. It is a required arg. -if [ -z "$1" ]; then - echo $USAGE - exit 1 -else - cp $1 $TMPF1 -fi - -echo >>$TMPF1 -echo "_done" >>$TMPF1 - -# -# First, strip all continuation characters, leaving one, single line -# for each printer entry. -# - CONV_FIX=/usr/lib/print/conv_fix - - if [ -f $CONV_FIX ]; then - $CONV_FIX -f $TMPF1 -o $TMPF2 - if [ $? != 0 ]; then - echo "$0:" - gettext "Fatal Error: $CONV_FIX failed.\n" - gettext "Please contact your Sun support representative.\n" - exit 1 - fi - else - gettext "$0: Fatal: Cannot locate $CONV_FIX binary.\n" - gettext "Please contact your Sun support representative.\n" - exit 1 - fi - -# -# Continuation characters are now stripped. Continue processing. -# - /bin/sed -e "s/:[ ]*:/:/g" $TMPF2 > $FILE - -# -# Empty colons ":[ <TAB>]*:" are now stripped. Continue processing. -# - -nawk ' -BEGIN { - "uname -n" | getline ; - host = $0 ; - found = 0 ; - local_pr = 0; -} - -{ - FS=":"; OFS=":" ; - if ($0 !~ /^#/) - { - if ($0 ~ /^[_a-zA-Z0-9_]/) { # New entry - if ( found != 0 ) { - if ( "'$namelist'" == 1 ) - printer = names ; - else - printer = name[1] ; - - if ( "'$conversion'" == "printers" ) { - printf "\n%s:", names ; - for (key in values) { - if ((key != "rp") && - (key != "rm")) { - printf "\\\n\t:%s=%s:", - key, values[key] ; - delete values[key]; - } - } - if (values["rm"] != "") { - printf "\\\n\t:bsdaddr=%s,%s:", \ - values["rm"], \ - values["rp"] ; - if (values["rm"] == host) local_pr++; - } else { - printf "\\\n\t:bsdaddr=%s,%s:", \ - host, printer ; - local_pr++; - } - delete values["rp"]; - delete values["rm"]; - } else { - printf "\n%s:", names ; - for (key in values) { - if (key == "bsdaddr") { - split(values[key], - pair, ","); - printf "\\\n\t:%s=%s:", \ - "rm", pair[1] ; - if (pair[2] == "") - pair[2] = printer; - printf "\\\n\t:%s=%s:", \ - "rp", pair[2] ; - - } else if ((key == "br") || \ - (key == "fc") || \ - (key == "fs") || \ - (key == "mc") || \ - (key == "mx") || \ - (key == "pc") || \ - (key == "pl") || \ - (key == "pw") || \ - (key == "px") || \ - (key == "py") || \ - (key == "xc") || \ - (key == "xs")) - printf "\\\n\t:%s#%s:", \ - key, \ - values[key] ; - else if (values[key] == "true") - printf "\\\n\t:%s:", \ - key ; - else if (values[key] != "false") - printf "\\\n\t:%s=%s:", \ - key, \ - values[key] ; - delete values[key]; - } - } - } - split( $1, name, "|"); - names = $1 ; - found++; - } - - for ( i = 1 ; i <= NF ; i++ ) { - if (($i == names) || ($i == "") || \ - ($i == "\t")) - continue ; - if ((split( $i, pair, "=" ) != 2) && \ - (split( $i, pair, "\#") != 2)) - pair[2] = "true"; - - if (pair[1] != "" && pair[1] != " ") - values[pair[1]] = pair[2] ; - } - } -} -END { - printf "\n" ; - if (local_pr != 0) - printf "One or more printers are local, you may want to run lpadmin to configure LP server side operation\n" | "cat 1>&2" ; - -}' ${FILE} - -/bin/rm -f ${TMPF1} ${TMP2} ${FILE} - -exit 0 diff --git a/usr/src/cmd/print/scripts/desktop-print-management b/usr/src/cmd/print/scripts/desktop-print-management deleted file mode 100644 index 2cc915be36..0000000000 --- a/usr/src/cmd/print/scripts/desktop-print-management +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# This interface launches an available print management tool capable of -# configuration management of the LP print service. -# -exec /usr/bin/ospm-pm -exec /bin/gksu /usr/sbin/printmgr -/bin/zenity --error --test "unable to locate a desktop print management tool" -exit 0 diff --git a/usr/src/cmd/print/scripts/desktop-print-management-applet b/usr/src/cmd/print/scripts/desktop-print-management-applet deleted file mode 100644 index 6a4932c8cf..0000000000 --- a/usr/src/cmd/print/scripts/desktop-print-management-applet +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# This interface launches any background desktop session service associated -# with the configuration management app for the LP service. -# -exec /usr/lib/ospm/ospm-applet -exit 0 diff --git a/usr/src/cmd/print/scripts/desktop-print-management-applet.desktop b/usr/src/cmd/print/scripts/desktop-print-management-applet.desktop deleted file mode 100644 index e227313fb2..0000000000 --- a/usr/src/cmd/print/scripts/desktop-print-management-applet.desktop +++ /dev/null @@ -1,37 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -[Desktop Entry] -Encoding=UTF-8 -Name=Desktop Printing Monitoring applet -Comment=Show balloon dialog for printers -Icon=print-manager -Exec=env DESKTOP_LAUNCHED=true /usr/bin/desktop-print-management-applet -Terminal=false -Type=Application -Categories= -OnlyShowIn=GNOME; -X-GNOME-Autostart-enabled=true diff --git a/usr/src/cmd/print/scripts/desktop-print-management-prefs b/usr/src/cmd/print/scripts/desktop-print-management-prefs deleted file mode 100644 index a0de4d1172..0000000000 --- a/usr/src/cmd/print/scripts/desktop-print-management-prefs +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# This interface launches an available print management tool capable of -# configuration management of the LP print service. -# -exec /usr/bin/ospm-preferences -/bin/zenity --error --test "preferences are unavailable for the desktop print management tool" -exit 0 diff --git a/usr/src/cmd/print/scripts/desktop-print-management-prefs.desktop b/usr/src/cmd/print/scripts/desktop-print-management-prefs.desktop deleted file mode 100644 index 970861d7e9..0000000000 --- a/usr/src/cmd/print/scripts/desktop-print-management-prefs.desktop +++ /dev/null @@ -1,56 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -[Desktop Entry] -Name=Printers -Name[de]=Drucker -Name[es]=Impresoras -Name[fr]=Imprimantes -Name[it]=Stampanti -Name[ja]=プリンタ -Name[ko]=프린터 -Name[pt_BR]=Impressoras -Name[zh_CN]=打印机 -Name[zh_HK]=印表機 -Name[zh_TW]=印表機 -Comment=Set printer detection and connection behavior -Comment[de]=Verhalten für Druckererkennung und -verbindung festlegen -Comment[es]=Definir la detección de impresoras y el comportamiento de conexión -Comment[fr]=Définir la détection des imprimantes et le comportement des connexions -Comment[it]=Impostare la rilevazione della stampante e il comportamento della connessione -Comment[ja]=プリンタの検出および接続の動作を設定します -Comment[ko]=프린터 감지 및 연결 동작 설정 -Comment[pt_BR]=Definir comportamento de conexão e detecção da impressora -Comment[zh_CN]=设置打印机检测和连接行为 -Comment[zh_HK]=設定印表機偵測和連線的運作方式 -Comment[zh_TW]=設定印表機偵測和連線的運作方式 -Exec=env DESKTOP_LAUNCHED=true /usr/bin/desktop-print-management-prefs -Icon=print-manager -Terminal=false -Type=Application -StartupNotify=true -Categories=GNOME;GTK;Settings; -OnlyShowIn=GNOME; diff --git a/usr/src/cmd/print/scripts/desktop-print-management.desktop b/usr/src/cmd/print/scripts/desktop-print-management.desktop deleted file mode 100644 index 168ebc75ee..0000000000 --- a/usr/src/cmd/print/scripts/desktop-print-management.desktop +++ /dev/null @@ -1,47 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -[Desktop Entry] -Name=Print Manager -Comment=Manage your printer queues and jobs -Comment[cs]=Správa tiskových front a procesů -Comment[de]=Druckerwarteschlangen und Druckaufträge verwalten -Comment[es]=Administre las tareas y colas de la impresora -Comment[fr]=Gérer les files d'attente et travaux de l'imprimante -Comment[it]=Gestisci le code e i processi della stampante -Comment[ja]=プリンタのキューおよびジョブを管理する -Comment[ko]=프린터 대기열 및 작업 관리 -Comment[pt_BR]=Gerenciar filas e trabalhos da impressora -Comment[zh_CN]=管理打印机队列和作业 -Comment[zh_HK]=管理印表機佇列和工作 -Comment[zh_TW]=管理印表機佇列和工作 -Exec=env DESKTOP_LAUNCHED=true /usr/bin/desktop-print-management -Icon=print-manager -Terminal=false -Type=Application -StartupNotify=true -Categories=GNOME;Application;System;Settings -OnlyShowIn=GNOME; diff --git a/usr/src/cmd/print/scripts/getmakes b/usr/src/cmd/print/scripts/getmakes deleted file mode 100644 index 437d268324..0000000000 --- a/usr/src/cmd/print/scripts/getmakes +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# -# get a list of the Manufacturers from the ppdcache -# - -[[ -f /var/lp/ppd/ppdcache ]] || exit 1 -/bin/cat /var/lp/ppd/ppdcache | - nawk '{FS=":"; print $1}' | - nawk '{print $1}' | - /bin/sort -u -exit 0 diff --git a/usr/src/cmd/print/scripts/getmodels b/usr/src/cmd/print/scripts/getmodels deleted file mode 100644 index eeb4309ce2..0000000000 --- a/usr/src/cmd/print/scripts/getmodels +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# -# get a list of the Models for this Model from the ppdcache -# -# Input: -# Manufacturer (Note: printmgr passes only the first word -# Lexmark of the manufacturer name) -# Output: -# Manufacturer Model -# Lexmark Optra Color 1200 - -if [[ $# -lt 1 ]]; then - exit 1 -fi - -cachefile=/var/lp/ppd/ppdcache -[[ -f $cachefile ]] || exit 1 -/bin/grep "^$1" $cachefile | nawk '{FS=":"; print $2}' | uniq -exit 0 diff --git a/usr/src/cmd/print/scripts/getppdfile b/usr/src/cmd/print/scripts/getppdfile deleted file mode 100644 index bba0590b1b..0000000000 --- a/usr/src/cmd/print/scripts/getppdfile +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# -# Get the path/ppdfilename for this ppd NickName -# Input: -# make: model: ppdlabel: ppd: -# PrintersRus: ABC Model 1234: SUNWfoomatic(S): Foomatic/Postscript (recommended): -# - -# -# Returns the full path to the repository associated with -# the repository letter found between parenthesis in the -# extended PPD label. -# -# $1 - Extended PPD label -# -rep_path() -{ - case "$(expr \"$1\" : ".*(\(.*\)).*")" in - "S") - echo "/usr/share/ppd" - ;; - "V") - echo "/opt/share/ppd" - ;; - "A") - echo "/usr/local/share/ppd" - ;; - "U") - echo "/var/lp/ppd" - ;; - esac -} - -if [[ $# -lt 4 ]]; then - exit 1 -fi - -[[ -f /var/lp/ppd/ppdcache ]] || exit 1 -make=$(echo $* | /usr/bin/nawk '{FS=":"; print $1}') -# strip leading blanks -model=$(echo $* | /usr/bin/nawk '{FS=":"; print $2}' | - /bin/sed -e 's/^[ ]*//') -extppdlabel=$(echo $* | /usr/bin/nawk '{FS=":"; print $3}' | - /bin/sed -e 's/^[ ]*//') -ppd=$(echo $* | /usr/bin/nawk '{FS=":"; print $4}' | - /bin/sed -e 's/^[ ]*//') - -# -# Do not use ":" with $make. printmgr collapses manufacturer name -# to first word, ie PrintersRus and PrintersRus International become -# PrintersRus. The full path to the PPD file will be the 6th -# colon separated entry in the ppdcache entry. If the format -# of a ppdcache entry changes, then this will need to be modified -# also. -# -/bin/grep "${make}" /var/lp/ppd/ppdcache | - /bin/grep "${model}:" | - /bin/grep "${ppd}:" | - /bin/grep "$(rep_path ${extppdlabel})/${extppdlabel%\(*}" | - /usr/bin/nawk '{FS=":"; print $6}' - -exit 0 diff --git a/usr/src/cmd/print/scripts/getppds b/usr/src/cmd/print/scripts/getppds deleted file mode 100644 index de91dadef4..0000000000 --- a/usr/src/cmd/print/scripts/getppds +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# get a list of the Models for this Model from the ppdcache -# - -# Input: -# make model -# HP OfficeJet 4200 -# Output: -# <label>(<repository letter>): <driver> -# userlabel(U): Foomatic/hpijs (recommended) -# SUNWhpijs(S): Foomatic/hpijs (recommended) - -SaveIFS="$IFS" -NoSpaceTabIFS=' -' -SEP=": " - -# -# Return cache entries matching the specified make -# and model from the specified cache file. -# -# $1 - Make -# $2 - Model -# $3 - cachefile -ppd_make_entries() -{ - for hit in $(/bin/grep "${1}" "${3}" | /bin/grep ":${2}:") - do - echo "${hit#*:*:}" - done -} - -if [[ $# -lt 2 ]]; then - exit 1 -fi - -cachefile=/var/lp/ppd/ppdcache -[[ -f $cachefile ]] || exit 1 -make=$1 -shift -model="$*" -system= -vendor= -admin= -user= - -# -# Ensure each ppdcache entry is processed as a single string -# otherwise it would be split up by spaces. -# -IFS="$NoSpaceTabIFS" -for pentry in $(ppd_make_entries "${make}" "${model}" "${cachefile}") -do - IFS="$SaveIFS" - ppdpath="${pentry##*:}" - ppdlpath="${ppdpath%/*/*}" - ppdlabel="${ppdlpath##*/}" - driver="${pentry%%:*}" - - case "${ppdpath}" in - "/usr/share/ppd/"*) - system="${system}${ppdlabel}(S)${SEP}${driver}\n" - ;; - "/opt/share/ppd/"*) - vendor="${vendor}${ppdlabel}(V)${SEP}${driver}\n" - ;; - "/usr/local/share/ppd/"*) - admin="${admin}${ppdlabel}(A)${SEP}${driver}\n" - ;; - "/var/lp/ppd/"*) - user="${user}${ppdlabel}(U)${SEP}${driver}\n" - ;; - esac - IFS="$NoSpaceTabIFS" -done - -IFS="$SaveIFS" -echo "${user}${admin}${vendor}${system}" -exit 0 diff --git a/usr/src/cmd/print/scripts/lpadmin b/usr/src/cmd/print/scripts/lpadmin deleted file mode 100644 index 04c144a21f..0000000000 --- a/usr/src/cmd/print/scripts/lpadmin +++ /dev/null @@ -1,403 +0,0 @@ -#!/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -PATH=/bin:/usr/bin:/usr/sbin export PATH - -TEXTDOMAIN="SUNW_OST_OSCMD" -export TEXTDOMAIN - -PFEXEC=/usr/bin/pfexec -LPSET=/usr/bin/lpset -LPGET=/usr/bin/lpget -LPSTAT=/usr/bin/lpstat -LPADMIN=/usr/lib/lp/local/lpadmin -LPFILTER=/usr/sbin/lpfilter -COMM=/usr/bin/comm -PPDMGR=/usr/sbin/ppdmgr -MKTEMP="/usr/bin/mktemp -t" - -HOST=$(/bin/uname -n) -exit_code=0 - -usage() { - gettext "Usage:\n" 1>&2 - gettext " lpadmin -p (printer) (options)\n" 1>&2 - gettext " lpadmin -x (dest)\n" 1>&2 - gettext " lpadmin -d (dest)\n" 1>&2 - gettext " lpadmin -S print-wheel -A alert-type [ -W minutes ]\n" 1>&2 - gettext " [ -Q requests ]\n" 1>&2 - gettext " lpadmin -M -f form-name [ -a [ -o filebreak ]\n" 1>&2 - gettext " [ -t tray-number ]]\n" 1>&2 - exit 1 -} - -# create a filter table for LP service -lp_config_filters() { - if [[ ! -f /etc/lp/filter.table ]] ; then - cd /etc/lp/fd ; for filter in *.fd ; do - ${PFEXEC} ${LPFILTER} \ - -f $(/usr/bin/basename $filter .fd) \ - -F $filter - done - fi -} - -# enable/disable LP related service(s) -lp_config_service() { # (enable | disable) - svcadm ${1} -s svc:/application/print/server:default - # svcadm ${1} -s svc:/application/print/rfc1179:default - # svcadm ${1} -s svc:/application/print/ipp-listener:default -} - -# synchronize printers.conf with LP configuration changes -lp_config_sync_pconf() { # (pre) (post) - ADDED=$(${COMM} -13 ${1} ${2}) - REMOVED=$(${COMM} -23 ${1} ${2}) - - lp_server=${server:-${HOST}} - for DEST in ${ADDED} ; do - lp_uri="ipp://${lp_server}/printers/${DEST}" - lp_bsdaddr="${lp_server},${DEST},Solaris" - ${LPSET} -n system \ - -a "printer-uri-supported=${lp_uri}" \ - -a "bsdaddr=${lp_bsdaddr}" \ - ${DEST} 2>/dev/null - done - - for DEST in ${REMOVED} ; do - ${LPSET} -n system -x ${DEST} 2>/dev/null - done -} - -# Delete all destinations in printers.conf -delete_all() { - for DEST in $(lpget -n system list | egrep -e '.+:$' | sed -e 's/://') - do - ${LPSET} -n system -x ${DEST} - status=$? - done -} - -# Call the ppdmgr utility to add a new PPD file to the system. -# -# $1 - path to PPD file -# $2 - label name (optional) -add_new_ppd_file() { - # Add new ppd file and echo full path it was actually saved to - ppdmgrcmd="${PFEXEC} ${PPDMGR} -a ${1} -w" - - ppderrfile=$(${MKTEMP} lpadminerror.XXXXXX) - if [[ -z "${ppderrfile}" ]] ; then - gettext "lpadmin: System error; cannot create temporary file\n" 1>&2 - exit 2 - fi - ppd_file=$(${ppdmgrcmd} 2>${ppderrfile}) - ppdmgrrc=$? - if [[ -s "${ppderrfile}" ]] ; then - print -n "lpadmin: " 1>&2 - cat ${ppderrfile} 1>&2 - rm -f ${ppderrfile} >/dev/null 2>&1 - if [[ ${ppdmgrrc} -ne 0 ]] ; then - exit 1 - fi - fi - rm -f ${ppderrfile} >/dev/null 2>&1 -} - -# -# Execution begins here -# - -# be sure that we can run lpset and lpget -if [[ ! -x ${LPSET} || ! -x ${LPGET} ]] ; then - gettext "lpadmin: System error; cannot set default printer\n" 1>&2 - exit 2 -fi - -if [[ $# -lt 1 ]] ; then - usage - exit 1 -fi - -# Deal with the -d option independently since getopts does not handle -# options that may or may not have arguments -# -if [[ ${1} = "-d" ]] ; then - if [[ $# -eq 1 ]] ; then # remove the "default" - ${LPGET} -n system _default >/dev/null 2>&1 - exit_code=$? - - if [[ ${exit_code} -eq 0 ]] ; then - ${LPSET} -n system -x _default - exit_code=$? - else # no default, nothing to do - exit_code=0 - fi - elif [[ $# -eq 2 ]] ; then # add/change the "default" - ${LPGET} -k bsdaddr ${2} >/dev/null 2>&1 - exit_code=$? - - if [[ $exit_code -eq 0 ]] ; then - ${LPSET} -n system -a "use=${2}" _default - exit_code=$? - else # can't set default to an unconfigured printer - gettext "${2}: undefined printer\n" 1>&1 - fi - else # invalid usage - usage - exit 1 - fi - - exit ${exit_code} -fi - -# Strip off legal options -while getopts "A:ac:D:e:f:F:H:hi:I:lm:Mn:o:p:Q:r:S:s:T:u:U:v:W:x:t:P:" arg -do - case $arg in - D) - description="${OPTARG}" - ;; - n) - ppd_file="${OPTARG}" - ;; - p) - if [[ -n "${delete}" ]] ; then - usage - fi - printer=${OPTARG} - ;; - s) - server=${OPTARG} - ;; - v|U) - device=${OPTARG} - if [[ ! -n "${server}" ]] ; then - server=${HOST} - fi - local="true" - ;; - x) - if [[ -n "${printer}" || -n "${server}" || \ - -n "${device}" || -n "${description}" ]] ; then - usage - fi - delete=${OPTARG} - printer=${OPTARG} - if [[ ${printer} = "all" ]] ; then - local="true" - fi - ;; - S|M|A) - local="true" - ;; - c) - class=${OPTARG} - local="true" - if [[ ! -f ${LPGET} ]] ; then - gettext "lpadmin: System error; cannot set class\n " 1>&2 - exit 2 - fi - - ${LPGET} "${class}" > /dev/null 2>&1 - lpget_class=$? - if [[ ${lpget_class} -eq 0 && ! -r /etc/lp/classes/"${class}" ]] ; then - gettext "lpadmin: ERROR: Can't create class ${class}.\n" 1>&2 - gettext " TO FIX: This is an existing printer name;\n" 1>&2 - gettext " choose another name.\n" 1>&2 - exit 1 - fi - ;; - r) - local="true" - ;; - esac -done - -# -# We don't have anything to do; let user know and bail -# -if [[ ! -n "${printer}" && ! -n "${delete}" && ! -n "${local}" ]] ; then - gettext "lpadmin: ERROR: Nothing to do.\n" 1>&2 - gettext " TO FIX: You must give one of these options:\n" 1>&2 - gettext " -p, -d, -x -S\n" 1>&2 - exit 1 -fi - -# -# Printer does not exist -# To be consistent with 2.5, assume adding local printer -# -if [[ ! -n "${device}" && ! -n "${server}" && ! -n "${delete}" && \ - ! -n "${local}" ]] ; then - ${LPGET} "${printer}" > /dev/null 2>&1 - lpget_stat=$? - if [[ ${lpget_stat} -ne 0 ]] ; then - gettext "lpadmin: ERROR: Missing -U or -v option.\n" 1>&2 - gettext " TO FIX: Local printers must have\n" 1>&2 - gettext " a port defined (-v option) or\n" 1>&2 - gettext " have dial-out instructions (-U option).\n" 1>&2 - exit 1 - fi -fi - -# process the "server" value -# It can be a hostname, UUCP form (server!queue), RCMD form(queue@server), -# or in URI form ({scheme}://{endpoint}) -# -case "${server}" in - *://*) # URI form - uri=${server} - rem_printer=$(expr "${server}" : ".*://.*/\([^/]*\)") - server=$(expr "${server}" : ".*://\([^/]*\)/.*") - ;; - *@*) # RCMD form - rem_printer=$(expr "${server}" : "\(.*\)@.*") - server=$(expr "${server}" : ".*@\(.*\)") - ;; - *!*) # UUCP form - rem_printer=$(expr "${server}" : ".*!\(.*\)") - server=$(expr "${server}" : "\(.*\)!.*") - ;; - *) # hostname - rem_printer=${printer} - ;; -esac - -# if there is a "device" or LP configuration, it's local -if [[ -n "${device}" || -f /etc/lp/printers/${printer}/configuration || \ - -f /etc/lp/classes/${printer} ]] ; then - local="true" -fi - -# Do the LP configuration for a local printer served by lpsched -if [[ -x ${LPADMIN} && -n "${local}" ]] ; then - # enumerate LP configured printers before modification - PRE=$(${MKTEMP} lpadmin-pre.XXXXXX) - if [[ -z "${PRE}" ]] ; then - gettext "lpadmin: System error; cannot create temporary file\n" 1>&2 - exit 2 - fi - - (/bin/ls /etc/lp/printers 2>/dev/null ; /bin/ls /etc/lp/classes \ - 2>/dev/null) >${PRE} - - # if there are no printers configured, enable LP service(s) - [[ ! -s "${PRE}" ]] && lp_config_service enable - - # add filters to LP service - lp_config_filters - - # add new ppd file to PPD file repositories - if [[ -n "${ppd_file}" && -x ${PPDMGR} ]] ; then - add_new_ppd_file "${ppd_file}" - fi - - # modify LP destination(s) - CMD="${PFEXEC} ${LPADMIN}" - while [[ -n "$*" ]] ; do # to deal with multi-word arguments - CMD="$CMD \"$1\"" - # replace the ppd_file originally specified with the -n option - # with the one returned from call to ppdmgr - if [[ "${1}" = "-n" ]] ; then - CMD="$CMD \"${ppd_file}\"" - shift - fi - shift - done - case "$CMD" in - *\"-D\") - CMD="$CMD \"\"" - ;; - esac - - # execute the LP lpadmin command - eval $CMD - exit_code=$? - - # enumerate LP configured printers after modification - POST=$(${MKTEMP} lpadmin-post.XXXXXX) - if [[ -z "${POST}" ]] ; then - gettext "lpadmin: System error; cannot create temporary file\n" 1>&2 - /bin/rm -f ${PRE} >/dev/null 2>&1 - exit 2 - fi - - (/bin/ls /etc/lp/printers 2>/dev/null ; /bin/ls /etc/lp/classes \ - 2>/dev/null) >${POST} - - # if there are no destinations, disable the service(s) - [[ ! -s "${POST}" ]] && lp_config_service disable - - # sync printers.conf with LP configuration - lp_config_sync_pconf "${PRE}" "${POST}" - - /bin/rm -f ${PRE} ${POST} -fi - -# Do any printers.conf configuration that is required -if [[ -n "${delete}" ]] ; then - if [[ "${delete}" = "all" ]] ; then - [[ $exit_code -eq 0 ]] && delete_all - elif [[ -z "${local}" ]] ; then - ${LPSET} -n system -x ${delete} - exit_code=$? - fi -else - if [[ -z "${local}" ]] ; then - # if we need a uri, find the "best" one. - if [[ -z "${uri}" ]] ; then - uri="ipp://${server}/printers/${rem_printer}" - ${LPSTAT} -p ${uri} >/dev/null 2>&1 - if [[ $? -ne 0 ]] ; then - uri="lpd://${server}/printers/${rem_printer}#Solaris" - fi - fi - # set the bsdaddr - bsdaddr="${server},${rem_printer},Solaris" - - if [[ -n "${printer}" && -n "${server}" ]] ; then - ${LPSET} -n system \ - -a "printer-uri-supported=${uri}" \ - -a "bsdaddr=${bsdaddr}" ${printer} - exit_code=$? - fi - - fi - - if [[ -n "${printer}" && -n "${description}" ]] ; then - ${LPSET} -n system \ - -a "description=${description}" ${printer} - exit_code=$? - fi -fi - -# if the "default" doesn't resolve a "bsdaddr", the printer is gone, remove it -${LPGET} -n system -k bsdaddr _default >/dev/null 2>&1 || - ${LPSET} -n system -x _default >/dev/null 2>&1 - -exit $exit_code diff --git a/usr/src/cmd/print/scripts/lpsystem b/usr/src/cmd/print/scripts/lpsystem deleted file mode 100644 index fdf08de324..0000000000 --- a/usr/src/cmd/print/scripts/lpsystem +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# - -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# This interface is obsolete, do nothing and always succeed for the sake -# of any shell scripts that may still make a call to it. -# -exit 0 diff --git a/usr/src/cmd/print/scripts/manufaliases b/usr/src/cmd/print/scripts/manufaliases deleted file mode 100644 index 4e6d489c36..0000000000 --- a/usr/src/cmd/print/scripts/manufaliases +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -Canon:Canon Inc. -Dymo:Dymo-CoStar -Epson -HP:hewlett-packard -Minolta:minolta-qms -Okidata:oki:OKI DATA CORP -Xerox -Lexmark:Lexmark International diff --git a/usr/src/cmd/print/scripts/ppdfilename2mmp b/usr/src/cmd/print/scripts/ppdfilename2mmp deleted file mode 100644 index 1d24c0af99..0000000000 --- a/usr/src/cmd/print/scripts/ppdfilename2mmp +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# -# Get the make/model/nickname as well as the repository/label from ppdfilename -# - -# Input -# ppdfilename -# /var/lp/ppd/user/HP/foo.ppd.gz -# Output -# make -# model -# label(repository letter): driver -# -# Lexmark -# IBM Page Printer 3112 -# foomatic(L): Foomatic/hpijs -# - -if [[ $# -lt 1 ]]; then - exit 1 -fi - -cachefile=/var/lp/ppd/ppdcache -[[ -f $cachefile ]] || exit 1 - -cacheentry=$(/bin/grep "$1" $cachefile) -[[ -n "$cacheentry" ]] || exit 1 - -# -# Retrieve the manufacturer (make) -# Use only the first word in manufacturer entry -# -manuf=$(echo "$cacheentry" | -nawk '{FS=":"; print $1}' | -nawk '{print $1}') - -# Retrieve the model -model=$(echo "$cacheentry" | nawk '{FS=":"; print $2}') - -# Retrieve the driver -driver=$(echo "$cacheentry" | nawk '{FS=":"; print $3}') - -# -# Retrieve the PPD path. Parse the PPD path to get the -# label path and to figure out the repository letter -# associated with the label path. Note: -# the PPD file name is the 6th colon separated entry -# in the cache entry. This is may need to be modified if the -# format changes. -# -ppdpath=$(echo "$cacheentry" | /bin/nawk '{FS=":"; print $6}' ) -manupath=$(/bin/dirname "$ppdpath") -labelpath=$(/bin/dirname "$manupath") - -case "$labelpath" in -/usr/share/ppd/*) - repltr=S - ;; -/opt/share/ppd/*) - repltr=V - ;; -/usr/local/share/ppd/*) - repltr=A - ;; -/var/lp/ppd/*) - repltr=U - ;; -esac - -[[ -n "${repltr}" ]] || exit 1 -echo "${manuf}\n${model}" -echo "$(/bin/basename "$labelpath")(${repltr}): $driver" - -exit 0 diff --git a/usr/src/cmd/print/scripts/ppdmgr b/usr/src/cmd/print/scripts/ppdmgr deleted file mode 100644 index 335c01da7d..0000000000 --- a/usr/src/cmd/print/scripts/ppdmgr +++ /dev/null @@ -1,1765 +0,0 @@ -#!/bin/ksh -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Description: Script to generate the Solaris printmgr 'ppdcache' file from the -# ppd files installed in the given ppd database directory -# -# ppdmgr -a <ppd_filename_path> [ -L <label> ] [-w] -# ppdmgr -g <ppd_filename_path> [ -L <label> ] [ -R <ppd_repository> ] -# ppdmgr -r [ -L <label> ] [ -R <ppd_repository> ] -# ppdmgr -u [ -L <label> ] [ -R <ppd_repository> ] -# -# Options: -# -a <ppd_filename_path> - Add a new PPD file to the specified -# label in the "user" repository, and -# updates to the "user" repository -# in the ppdcache. -# -g <ppd_filename_path> - Generate a cache file entry -# for the specified PPD file -# on standard out. -# -L <label> - Label name. <label> -# can be any characters from the -# portable character set, however -# may not contain a semi-colon (':'). -# The following are the defaults -# for <label> for each option: -# OPTION DEFAULT LABEL -# ------ ------------- -# -a <label> from <ppd_filename_path> -# if <ppd_filename_path> -# is from a known repository, -# otherwise defaults to "user". -# -g <label> from <ppd_filename_path> -# if <ppd_filename_path> -# is from a known repository, -# otherwise defaults to "user". -# -r all -# -u all -# The following are reserved labels: -# caches - may never be specified -# ppdcache - may never be specified -# manufaliases - may never be specified -# all - applies specified -# action to all labels -# in a repository. -# Can only be specified -# with -r or -u. -# SUNW* - anything starting with -# SUNW is reserved for -# use by Sun, but not -# prohibited. -# -r - Rebuild the cache information for the -# specified label in the specified -# repository. Similar to -u, however, -# the cache file is removed to force an -# update to the ppdcache. -# -R <ppd_repository> - PPD repository name. -# Defaults to "user". -# The following are the possible -# values for <ppd_repository> and -# location in the system: -# REP LOCATION -# --- -------- -# user /var/lp/ppd -# admin /usr/local/share/ppd -# vendor /opt/share/ppd -# system /usr/share/ppd -# all all repositories -# -# Note: When specified with the -a option -# only "user" and "admin" are valid. -# "vendor", "system", and "all" will be -# considered reserved. -# -u - Update the PPD cache information -# for the specified label in the specified -# repository if needed. If the cache -# update was required, then the updated -# cache information is reflected in -# the ppdcache. -# -w - Display full path of where the -# ppd file is located on the system. -# Only valid with -a, otherwise the -# option is ignored. -# -# If -a, -g, -r, or -u are specified on the command line, only the last action -# specified will be performed. -# -# Cache file entry format: -# <ModifiedManufacturerName>:<Model>:<NickName>:<1284DeviceIDManufacturer>:<1284DeviceIDModel>:<FullPPDFilePath> -# HP:HP DeskJet 450:Foomatic/hpijs (recommended):dj450:hp:/usr/share/ppd/HP/HP-DeskJet_450-hpijs.ppd.gz -# - -PATH=/bin:/usr/bin:/usr/sbin export PATH -set -o noclobber - -TEXTDOMAIN="SUNW_OST_OSCMD" -export TEXTDOMAIN - -# -# Generates debug output for calling routine. -# If calling routine's name is passed in, then -# will also generate the name of the calling routine. -# -# $1 - Name of calling routine -debugger() -{ - [[ ${debug} -eq 1 ]] || return 1 - if [[ -n "${1}" ]] ; then - echo "In ${1}..." 1>&2 - fi - return 0 -} - -# -# Set the ownership and permissions on a file. -# -# $1 - Mode -# $2 - Owner:Group -# $3 - Full path to file -# -set_perms() -{ - /bin/chmod -f ${1} "${3}" >/dev/null 2>&1 - /bin/chown -f ${2} "${3}" >/dev/null 2>&1 -} - -# -# Create administrator repository directories, /usr/local/share/ppd, -# if needed. This is a special case a Solaris doesn't deliver -# /usr/local/share and it has different permissions than the -# user repository. -# -# $1 - destination repository name -# -create_adminrep_dirs() -{ - if debugger "check_adminrep_dirs" ; then - set -x - fi - - # Only create administrator repository directories, if needed. - [[ "${1}" = "${ADMIN}" ]] || return 0 - - # Check /usr/local/share/ppd - [[ ! -d "${ADMINREP}" ]] || return 0 - - # Check /usr/local/share - admpar=$(/bin/dirname "${ADMINREP}") - if [[ ! -d "${admpar}" ]] ; then - - # Check /usr/local - admppar=$(/bin/dirname "${admpar}") - if [[ ! -d "${admppar}" ]] ; then - make_dir ${DIRMODE} ${ADMINOWNER} "${admppar}" || \ - return 1 - fi - make_dir ${DIRMODE} ${ADMINOWNER} "${admpar}" || return 1 - fi - make_dir ${DIRMODE} ${ADMINOWNER} ${ADMINREP} || return 1 - return 0 -} - -# -# Returns full path to PPD file that was added to the system. -# -# $1 - Full path to source PPD file -# $2 - PPD file name -# $3 - Full path to repository -# $4 - Repository name -# $5 - Label name -# -# Return codes: -# 0 - File successfully added -# 1 - Error -# 2 - Duplicate file already exists -# -add_ppd() -{ - if debugger ; then - set -x - fi - - verify_ppd_file "${1}" - if [[ $? -ne 0 ]] ; then - gettext "invalid PPD file: ${1}" 2>/dev/null - return 3 - fi - - # The destination path can now be set - dstlabelpath="${3}/${5}" - dstmanufpath="${dstlabelpath}/${modmanuf}" - dstpath="${dstmanufpath}/${2}" - - # - # If a version (either compressed or not compressed) of the PPD - # file exists in the destination in the label/repository, - # then just return as there no work to be done. - dst_copy_path=$(variant_copy "${1}" "${dstpath}" "${6}" "${ppdfname}") - ap_rc=$? - if [[ ${ap_rc} -ne 0 ]] ; then - echo "${dst_copy_path}" - return ${ap_rc} - fi - - # - # Can only add a PPD file to the "user" or "admin" repository. - # Note: this check is here instead of at the top of this - # function as we don't want to cause an error if a user - # specifies the same repository and label as a the specified - # ppd file and the repository of the specified ppd file - # exists in a known repository. - # - if [[ "${4}" != "${USER}" && "${4}" != "${ADMIN}" ]] ; then - gettext "invalid PPD file repository name: ${4}" 2>/dev/null - return 3 - fi - - # Ensure destination directories exist - if ! create_adminrep_dirs ${4} ${DIRMODE} ${ADMINOWNER} || \ - ! make_dir ${DIRMODE} ${DIROWNER} "${3}" || \ - ! make_dir ${DIRMODE} ${DIROWNER} "${dstlabelpath}" || \ - ! make_dir ${DIRMODE} ${DIROWNER} "${dstmanufpath}" ; then - gettext "unable to create destination directories" 2>/dev/null - return 3 - fi - - # Copy source PPD file, and compress if needed, to destination - if [[ "${ppdfileext}" = "${PEXT}" ]] ; then - ${GZIP} "${1}" >"${dst_copy_path}" 2>/dev/null - if [[ $? -eq 1 ]] ; then - gettext "unable to copy PPD file " 2>/dev/null - gettext "to destination" 2>/dev/null - return 3 - fi - else - /bin/cp -f "${1}" "${dst_copy_path}" >/dev/null 2>&1 - if [[ $? -ne 0 ]] ; then - gettext "unable to copy PPD file " 2>/dev/null - gettext "to destination" 2>/dev/null - return 3 - fi - fi - set_perms ${FILEMODE} ${FILEOWNER} "${dst_copy_path}" - - echo "${dst_copy_path}" - - return 0 -} - -# -# Returns 0 if the cache needs to be modified, otherwise -# returns 1. -# -# $1 - Full path to cache -# $2 - Full path to cache replacement candidate -# -changes_in_cache() -{ - if debugger "changes_in_cache" ; then - set -x - fi - - if [[ "${action}" = "${REBUILD}" ]] ; then - return 0 - fi - [[ "${2}" -nt "${1}" ]] || return 1 - if $(${CMP} "${1}" "${2}" >/dev/null 2>&1) ; then - # No differences. Just update timestamp - /bin/touch -r "${2}" "${1}" >/dev/null 2>&1 - return 1 - else - return 0 - fi -} - -# -# Generate a new golden cache file (/var/lp/ppd/ppdcache), by -# concatenating and sorting all existing cache files in /var/lp/ppd/caches. -# -# If there are difference between the newly generated golden cache file and -# the existing one (if it exists) then the newly generated one replaces the -# existing one at /var/lp/ppd/ppdcache. -# -update_golden_cache() -{ - - if debugger "update_golden_cache" ; then - set -x - fi - - # - # Remove any cache files that don't have an associated - # label. - # - for cname in $(/bin/ls ${VARCACHES} 2>/dev/null) ; do - repname="${cname%%:*}" - cfile="${cname#*:}" - checkdir="$(get_rep_path ${repname})/${cfile}" - remove_unassociated_cache "${checkdir}" "${cname}" - done - - # - # Combine the contents of all cache files into a - # temporary golden cache file. - # - tmpgoldencache=$ppdmgrtmpdir/tmpgoldencache - - /bin/sort "${VARCACHES}"/* >>"${tmpgoldencache}" 2>/dev/null - - if [[ ! -s "${tmpgoldencache}" ]] ; then - # No cache files. Remove golden cache. - /bin/rm -f "${GOLDCACHE}" >/dev/null 2>&1 - /bin/rm -f "${tmpgoldencache}" >/dev/null 2>&1 - elif [[ -e "${GOLDCACHE}" ]] ; then - # - # Use the newly generated "temporary" golden cache file if there - # differences between the current and newly generated ppdcache - # or if a rebuild is being performed. - # - if [[ "${VARCACHES}" -nt "${GOLDCACHE}" ]] || \ - changes_in_cache "${GOLDCACHE}" "${tmpgoldencache}" ; then - set_perms ${FILEMODE} ${FILEOWNER} "${tmpgoldencache}" - /bin/mv -f "${tmpgoldencache}" \ - "${GOLDCACHE}" >/dev/null 2>&1 - else - /bin/rm -f "${tmpgoldencache}" >/dev/null 2>&1 - fi - else - # There wasn't an existing ppdcache. Install the newly - # generated ppdcache file to the golden ppdcache. - set_perms ${FILEMODE} ${FILEOWNER} "${tmpgoldencache}" - /bin/mv -f "${tmpgoldencache}" "${GOLDCACHE}" >/dev/null 2>&1 - fi -} - -# -# Returns a list of PPD files that exist. -# -# $1 - Full path to cache file -# -remove_invalid_cache_entries() -{ - if debugger ; then - set -x - fi - - [[ -s "${1}" ]] || return - - IFS="$NoSpaceTabIFS" - for centry in $(/bin/cat "${1}" 2>/dev/null) ; do - IFS="$SaveIFS" - # - # Keep the entry from the ppd cache if it still - # exists and there haven't been any modifications - # since the last update to the cache. - # - if [[ -n "${centry}" ]] ; then - ppdfile="${centry##*:}" - if [[ -n "${ppdfile}" && -e "${ppdfile}" && - "${1}" -nt "${ppdfile}" ]] ; then - echo "${centry}" - fi - fi - IFS="$NoSpaceTabIFS" - done - IFS="$SaveIFS" -} - -# -# Returns 0 if the path to the PPD is as follows: -# <PPD file repository>/<label>/<manufacturer>/<PPD file> -# otherwise, returns 1 -# -# $1 Full path to PPD file -# -verify_ppd_location() -{ - if debugger ; then - set -x - fi - - # - # Strip off what should be <label>/<manufacturer>/<PPD file> - # and verify the PPD file repository matches one of the - # known PPD file repositories. - # - ppd_file_repository=${1%/*/*/*} - found=1 - for repository in ${REPOSITORIES} ; do - if [[ "${repository}" = "${ppd_file_repository}" ]] ; then - found=0 - break - fi - done - return ${found} -} - -# -# Generate, and sort, cache entries for each PPD files in the specified -# list to the specified file. -# -# $1 - List of full paths to PPD files -# $2 - Full path to current cache file -# $3 - Full path to label -# $4 - Full path to new cache file to generate -# -# Return code: -# 0 success -# 1 unsuccessful -# -generate_label_cache_file() -{ - if debugger ; then - set -x - fi - - # - # Generate a cache file containing cache entries for - # all files in the label. - # - ucfile=$ppdmgrtmpdir/unsortedcache - - # - # Before processing new files, remove any cache entries - # which may be invalid. - # - valid_files= - if [[ -e "${2}" && "${action}" != "${REBUILD}" ]] ; then - valid_files=$(remove_invalid_cache_entries "${2}") - if [[ -n "${valid_files}" ]] ; then - echo "${valid_files}" >>${ucfile} - fi - fi - - # - # If there are no valid PPD files in the current cache file, - # and there are no new PPD files to process, the only thing - # left to do is to remove the current cache file. - # - if [[ -z "${valid_files}" && -z "${1}" ]] ; then - /bin/rm -f "${2}" >/dev/null 2>&1 - /bin/rm -f "${ucfile}" >/dev/null 2>&1 - return 0 - fi - - # - # For each of the label's PPD files, generate - # a cache file entry and add it to the cache file. - # - vpl_rc=0 - vpf_rc=0 - vpl_msg= - vpf_msg= - IFS="$NoSpaceTabIFS" - for fname in ${1} ; do - IFS="$SaveIFS" - if [[ -n "${fname}" ]] ; then - verify_ppd_location "${fname}" - vpl_rc=$? - if [[ ${vpl_rc} -ne 0 ]] ; then - vpl_msg="${vpl_msg}\t${fname}\n" - fi - - verify_ppd_file "${fname}" - vpf_rc=$? - if [[ ${vpf_rc} -ne 0 ]] ; then - vpf_msg="${vpf_msg}\t${fname}\n" - fi - - if [[ ${vpl_rc} -eq 0 && ${vpf_rc} -eq 0 ]] ; then - echo "$(generate_cache_file_entry \ - "${modmanuf}" "${model}" "${nickn}" \ - "${devidmfg}" "${devidmdl}" "${fname}")" - fi - fi - IFS="$NoSpaceTabIFS" - done >>"${ucfile}" - IFS="$SaveIFS" - /bin/sort -u "${ucfile}" >>"${4}" 2>/dev/null - /bin/rm -f "${ucfile}" >/dev/null 2>&1 - - [[ -n "${vpl_msg}" || -n "${vpf_msg}" ]] || return 0 - if [[ -n ${vpl_msg} ]] ; then - gettext " PPD file(s) not in valid location\n" 2>/dev/null - gettext \ - " (<repository>/<label>/<manufacturer>/<PPD file>):\n" 2>/dev/null - echo "${vpl_msg}" - fi - if [[ -n ${vpf_msg} ]] ; then - gettext " invalid PPD file(s):\n" 2>/dev/null - echo "${vpf_msg}" - fi - return 1 -} - -# -# Update current cache file with candidate cache file if there are -# differences. -# -# $1 - Current cache file -# $2 - Candidate cache file to update -# $3 - Repository name -# -update_current_cache_file() -{ - if debugger "update_current_cache_file" ; then - set -x - fi - - if [[ ! -s "${2}" ]] ; then - # - # Candidate cache has zero size (label - # directory with no PPD files under it). - # Delete the empty candidate cache - # file and delete the current cache - # file. - # - /bin/rm -f "${1}" >/dev/null 2>&1 - /bin/rm -f "${2}" >/dev/null 2>&1 - elif [[ -e "${1}" ]] ; then - # - # If there are differences between the current - # cache file and the newly generated one, then - # replace the current one with the new one, and - # set the flag to update the golden ppdcache - # file. - # - if changes_in_cache "${1}" "${2}" ; then - set_perms ${FILEMODE} ${FILEOWNER} "${2}" - /bin/mv -f "${2}" "${1}" >/dev/null 2>&1 - else - /bin/rm -f "${2}" >/dev/null 2>&1 - fi - else - - # - # There is no current cache file. Move the candidate - # to the caches directory. - # - set_perms ${FILEMODE} ${FILEOWNER} "${2}" - /bin/mv -f "${2}" "${1}" >/dev/null 2>&1 - fi -} - -# -# Returns 0 if there are files in $1 with newer timestamp -# than $2 or if deletions have occurred under $1, -# otherwise returns 1. -# -# $1 - Full path to the destination label -# $2 - Full path to label cache file -# -changes_under_label() -{ - if debugger ; then - set -x - fi - - # First check for newer files in the directory - if [[ -e "${2}" && "${action}" != "${REBUILD}" ]] ; then - newfiles=$(/bin/find "${1}" -type f -newer "${2}") - else - newfiles=$(/bin/find "${1}" -type f) - fi - echo "${newfiles}" - [[ -z "${newfiles}" ]] || return 0 - - # - # Need to detect if PPD files have been deleted by checking - # timestamps on label and manufacturer directories. - # - [[ ! "${1}" -nt "${2}" ]] || return 0 - /bin/find "${1}" -type d -newer "${2}" >/dev/null 2>&1 || return 1 - return 0 -} - -# -# If -R was specified, or the timestamp on the specified label's -# directory or any of the PPD files under the specified label in -# the specified PPD file respository is newer than the cache file -# associated with the label, then generate a new sorted cache file. -# -# The new cache will replace the existing one (if any) only if there -# are differences. Note: if -r was specified, then a new cache file -# file will always be installed at -# /var/lp/ppd/caches/<PPD file repository name>-<label name> -# -# $1 - Full path of the destination PPD file repository -# $2 - Destination PPD file repository name -# $3 - Destination label name -# -update_label_cache() -{ - if debugger ; then - set -x - fi - - dstlabelpath="${1}/${3}" - replabelcachepath="${1}/${CACHES}/${3}" - varlabelcachepath="${VARCACHES}/${2}${SEP}${3}" - - ulc_rc=0 - if [[ -d "${dstlabelpath}" ]] ; then - - # - # If the cache doesn't exist for a label, - # or if there were any changes under a label - # (i.e., the timestamp on the label directory or any - # of the PPD files under it is newer than the - # existing cache file), then generate a new cache file. - # - tmpcachepath=$ppdmgrtmpdir/tmpcachepath - - # if this is a system repository, check for a prepopulated cache - if [[ "${2}" = "${SYSTEM}" && -e ${FOOCACHEDIR}/${3}.cache ]] ; then - # copy prepopulated cache - /bin/cp -f ${FOOCACHEDIR}/${3}.cache ${tmpcachepath} - - else - newfileslist=$(changes_under_label "${dstlabelpath}" \ - "${varlabelcachepath}") - if [[ $? -eq 0 ]] ; then - err_files=$(generate_label_cache_file \ - "${newfileslist}" "${varlabelcachepath}" \ - "${dstlabelpath}" "${tmpcachepath}") - if [[ $? -ne 0 ]] ; then - # - # At least one PPD file was invalid. - # Don't return yet, as the cache info - # for the valid PPD files can still be - # used to generate a cache file. - # - echo "${err_files}" - ulc_rc=1 - fi - fi - fi - - if [[ -e "${tmpcachepath}" ]] ; then - update_current_cache_file \ - "${varlabelcachepath}" "${tmpcachepath}" "${2}" - /bin/rm -f "${tmpcachepath}" >/dev/null 2>&1 - fi - else - # - # If there is a cache file in /var/lp/ppd/caches associated - # with the label which no longer exists, remove it. - # - /bin/rm -f "${varlabelcachepath}" >/dev/null 2>&1 - fi - return ${ulc_rc} -} - -# -# Returns the alias for the specified real manufacturer's name. -# -# $1 - Real manufacturer's name -# $2 - File containing list of files that have manufacturers aliases -# -manuf_name_alias() -{ - if debugger ; then - set -x - fi - - # - # Found a couple of PPD files which had special characters - # in the Manufacturer name (i.e, the following is the Manufacturer - # entry: - # *Manufacturer: "Canon Inc. (Kosugi Offic" - # We'll only search the alias file for "Canon Inc." - # - tmpmanuf="${1% *\(*}" - - # Search alias files for a match on the real manufacturer name - if [[ -s "${2}" ]] ; then - # - # Check the manufacturer aliases file for case - # insensitive match of the Manufacturer entry - # from the PPD file. If a match is found, - # then modify the manufacturer entry to - # be that of the specified alias. - # - manufaliases=$(/bin/egrep -i \ - "^${tmpmanuf}:|:${tmpmanuf}:|:${tmpmanuf}$" "${2}") - if [[ -n "${manufaliases}" ]] ; then - echo "${manufaliases%%:*}" - break - else - echo "${tmpmanuf}" - fi - else - echo "${tmpmanuf}" - fi -} - -# -# Returns 0 if the extension to the specified PPD file is a known -# extension, otherwise returns 1. -# -# $1 - Full path to PPD file -# -# Set upon return: -# ppdfileext - PPD file ext (.ppd or .ppd.gz) -# -verify_file_ext() -{ - if debugger ; then - set -x - fi - - if [[ "${1%.gz}".gz = "${1}" ]] ; then - ppdfileext=${GEXT} - elif [[ "${1%.ppd}".ppd = "${1}" ]] ; then - ppdfileext=${PEXT} - else - # invalid PPD file name extension - return 1 - fi - - return 0 -} - -# -# Return the lines from the specified PPD file matching the specified -# spec items. -# -# $1 - spec entries from PPD file -# $2 - spec item -# -# $1 example - 1 string with substrings separated by newline: -# *PPD-Adobe: "4.3" -# *Manufacturer: "HP" -# *Product: "(officejet 4200 series)" -# *ModelName: "HP OfficeJet 4200" -# *NickName: "HP OfficeJet 4200 Foomatic/hpijs (recommended)" -# $2 example: -# ^\*Manufacturer -# -spec_entry() -{ - if debugger ; then - set -x - fi - - item=$(echo "${1}" | /bin/grep ${2}) - # Remove everything up to and including the first quote - item=${item#*\"} - # Remove the end quote - echo "${item%\"}" -} - -# -# Return the lines from the specified PPD file matching the specified -# spec items. -# -# Note: this is similar to spec_entry() except the tokens in the -# spec entry are different. -# -# $1 - spec entries from PPD file -# $2 - spec item -# -devid_spec_entry() -{ - if debugger ; then - set -x - fi - - item=$(echo "${1}" | /bin/grep ${2}) - # Remove everything up to and including the first semi-colon - item=${item#*\:} - # Remove the end quote - echo ${item%\;} - -} - -# -# Verifies that the specified PPD file -# - has a valid extension -# - has the following required spec file entries: -# *PPD-Adobe: "4.3" -# Manufacturer -# Product -# ModelName -# NickName -# -# In addition, the manufacture and model from the IEEE1284 device id -# information will be gathered here, although it's not an error that -# it isn't in the PPD file as many don't contain the IEEE1284 info. -# -# $1 - Full path to PPD file -# -# Return codes: -# 0 success -# 1 invalid PPD file -# -verify_ppd_file() -{ - if debugger ; then - set -x - fi - - ADOBESPEC="PPD-Adobe" - MANUF="Manufacturer" - PRODUCT="Product" - MODEL="ModelName" - NICKNAME="NickName" - DEVID="1284DeviceID" - - # Verify the PPD file extension - verify_file_ext "${1}" || return 1 - - # Query for the required spec items - searchentries="^\*${ADOBESPEC}:|^\*${MANUF}:|^\*${PRODUCT}:" - searchentries="${searchentries}|^\*${MODEL}:|^\*${NICKNAME}:" - searchentries="${searchentries}|^\*${DEVID}:" - ppd_info="$(/bin/gzgrep -e "${searchentries}" "${1}")" - - # - # Process the query results to verify each of the required spec - # file items appears in the PPD file. - # - for spec_item in ${ADOBESPEC} ${MANUF} ${PRODUCT} ${MODEL} \ - ${NICKNAME} ; do - entry=$(spec_entry "${ppd_info}" "^\*${spec_item}:") - [[ ! -z "${entry}" ]] || return 1 - case ${spec_item} in - ${MANUF}) - realmanuf="${entry}" - ;; - ${PRODUCT}) - product="${entry}" - ;; - ${MODEL}) - model="${entry}" - ;; - ${NICKNAME}) - # - # Remove the model and any commas and spaces - # which appear before the driver - # - nickn="${entry#$model[, ]*}" - ;; - esac - - done - - # Save IEEE1284 device id information - if $(echo "${ppd_info}" | grep "${DEVID}" >/dev/null 2>&1) ; then - DMDL="MDL" - DMFG="MFG" - devid="$(/bin/gzgrep -e "^[ ]*${DMDL}:|^[ ]*${DMFG}:" "${1}")" - devidmdl="$(devid_spec_entry "${devid}" "${DMDL}")" - devidmfg="$(devid_spec_entry "${devid}" "${DMFG}")" - else - devidmdl= - devidmfg= - fi - modmanuf=$(manuf_name_alias "${realmanuf}" ${aliasfile}) - - return 0 -} - -# -# generate_cache_file_entry() -# -# Returns a cache file entry for the specified PPD file. -# -# $1 - modmanuf -# $2 - model -# $3 - nickn -# $4 - devidmfg -# $5 - devidmdl -# $6 - Full path to the specified PPD file -# -generate_cache_file_entry() -{ - if debugger "generate_cache_file_entry" ; then - set -x - fi - - echo "${1}":"${2}":"${3}":"${4}":"${5}":"${6}" -} - -# -# Expand specified file to the full path. -# -# $1 - File path to expand -# -# Return code set to 0 if expanded successfully, otherwise set to 1. -# -ppd_pathname() -{ - if debugger ; then - set -x - fi - - if [[ -f "${1}" && -s "${1}" ]] ; then - (cd "$(/bin/dirname "${1}")" ; \ - echo "$(/bin/pwd)/$(/bin/basename "${1}")") || return 1 - return 0 - else - return 1 - fi -} - -# -# Returns the PPD repsitory path associated with the specified -# PPD repository name. -# -# $1 - Repository name -# -get_rep_path() -{ - if debugger ; then - set -x - fi - - case ${1} in - ${SYSTEM}) - echo "${SYSTEMREP}" - ;; - ${VENDOR}) - echo "${VENDORREP}" - ;; - ${ADMIN}) - echo "${ADMINREP}" - ;; - ${USER}) - echo "${USERREP}" - ;; - *) - echo "${UNSET}" - ;; - esac -} - -# -# Returns the PPD respository name from the repository path -# -# $1 - PPD repository path -# -get_rep_name() -{ - if debugger ; then - set -x - fi - - case ${1} in - ${SYSTEMREP}) - echo "${SYSTEM}" - ;; - ${VENDORREP}) - echo "${VENDOR}" - ;; - ${ADMINREP}) - echo "${ADMIN}" - ;; - ${USERREP}) - echo "${USER}" - ;; - "all") - echo "all" - ;; - *) - echo "${UNSET}" - ;; - esac -} - -# -# Returns 0 if a matching label name is found in the specified repository, -# otherwise returns 1. -# -# $1 - repository path -# $2 - label name -# -label_path_in_repository() -{ - if debugger "label_path_in_repository" ; then - set -x - fi - - [[ "${1}" != "" && "${2}" != "" ]] || return 1 - lpir_rc=1 - for repository in ${REPOSITORIES} ; do - if [[ "${repository}" = "${1}" && -d "${1}/${2}" ]] ; then - lpir_rc=0 - break - fi - done - return ${lpir_rc} -} - -# -# Returns 0 if the source label path is the same -# as the destination label path, otherwise returns 1. -# -# $1 - full path to source PPD file (source label path) -# $2 - destination repository path -# $3 - destination label name -# -label_path_match() -{ - if debugger "label_path_match" ; then - set -x - fi - - # dest repository not specified - if [[ "${2}" = "${UNSET}" ]] ; then - # dest label not specified - if [[ "${3}" = "${UNSET}" ]] ; then - # - # We've found a match if the label path is in a known - # repository. - # - lpath="${1%/*/*}" - label_path_in_repository \ - "${1%/*/*/*}" "${lpath##*/}" || return 1 - else - # - # If the source label path exists in the - # in a known repository, and the destination - # label is the same as the source label, - # then we'll assume the default destination - # repository is the same as the source - # destination repository. - # - [[ "${1%/*/*}" = "${1%/*/*/*}/${3}" ]] || return 1 - label_path_in_repository "${1%/*/*/*}" "${3}" || \ - return 1 - fi - - # dest repository specified, dest label not specified - elif [[ "${3}" = "${UNSET}" ]] ; then - # - # If the destination repository path is the same as the - # source repository, and if the source label exists in the - # destination repository path, then we'll assume the default - # destination label is the same as the source label. - # - [[ "${2}" = "${1%/*/*/*}" ]] || return 1 - lpath="${1%/*/*}" - label_path_in_repository "${2}" "${lpath##*/}" || return 1 - - # dest repository and dest label specified. - else - # - # We've found a match if the destination and label - # match those of the source label path, and the source - # label path is in a known repository. - # - [[ "${1%/*/*}" = "${2}/${3}" ]] || return 1 - label_path_in_repository "${2}" "${3}" || return 1 - fi - return 0 -} - -# -# Returns 0 if specified label name is a reserved label, otherwise -# returns 1. -# -# $1 - label name -# -reserved_label() -{ - if debugger ; then - set -x - fi - - rl_rc=1 - for labelname in ${RESERVEDLABELS} ; do - if [[ "${1}" = "${labelname}" ]] ; then - rl_rc=0 - break - fi - done - return ${rl_rc} -} - -# -# Returns a list of all labels that exist in a repository that are -# not reserved labels. -# -# $1 - Full path of repository -# $2 - Repository name -# -get_rep_label_list() -{ - if debugger ; then - set -x - fi - - # - # Get a list of all labels that exist in all of the - # PPD file repository. - # - for lname in $(/bin/ls "${1}" 2>/dev/null) ; do - if [[ -d "${1}/${lname}" ]] ; then - if ! reserved_label "${lname}" ; then - echo "${lname} " - fi - fi - done -} - -# -# Returns a valid PPD label. -# -# Verifies the specified PPD label is a valid label. If the -# label is not set, then it is set to a default value. -# -# Return code set to 0 if the specified PPD label is valid, otherwise 1. -# -# $1 - PPD label -# -valid_specified_label() -{ - if debugger ; then - set -x - fi - - # Verify the specified label - vsl_rc=0 - case "${1}" in - "all") - # Reserved label name with -a or -g options - if [[ "${action}" = "${ADD}" || \ - "${action}" = "${GENERATEENTRY}" ]] ; then - print -n "$myprog: " 1>&2 - gettext "reserved PPD label name: ${1}\n" 1>&2 - vsl_rc=1 - else - echo "${1}" - fi - ;; - - "ppdcache" | "caches" | "manufaliases") - # Reserved label names with any option - print -n "$myprog: " 1>&2 - gettext "reserved PPD label name: ${1}\n" 1>&2 - vsl_rc=1 - ;; - - "" | "${UNSET}") - # Label name not specified. Set the default label name. - # For -g and -a, default is "user", otherwise, default - # is "all". - if [[ "${action}" = "${ADD}" || \ - "${action}" = "${GENERATEENTRY}" ]] ; then - echo "${USER}" - else - echo "all" - fi - ;; - - *) - # label cannot be "." or ".." - if [[ "${1}" = "." || "${1}" = ".." ]] ; then - print -n "$myprog: " 1>&2 - gettext "PPD label name cannot be " 1>&2 - gettext "\".\" or \"..\"\n" 1>&2 - vsl_rc=1 - fi - - # Label name cannot contain special characters - echo "${1}" | /bin/egrep "${SPECIALCHARS}" >/dev/null - if [[ $? -eq 0 ]] ; then - print -n "$myprog: " 1>&2 - gettext "PPD label name contains " 1>&2 - gettext "an invalid character: ${1}\n" 1>&2 - vsl_rc=1 - else - echo "${1}" - fi - ;; - esac - return ${vsl_rc} -} - -# -# Returns the full path of any variant copy of the source file in -# the destination label/repository. -# -# $1 - Full path to source PPD file -# $2 - Full path to destination PPD file -# -# Return code set to -# 0 - Copy doesn't exist -# 1 - Duplicate copy exists -# 2 - Variant copy exists -# -variant_copy() -{ - if debugger ; then - set -x - fi - - # - # First make sure there is not a .ppd and a .ppd.gz version - # of the destination file; users should know not to do this. - # - if [[ -e "${2%.gz}" && -e "${2%.gz}.gz" ]] ; then - /bin/rm -f "${2%.gz}" >/dev/null 2>&1 - fi - - # Use gzcmp to compare PPD files as it can deal with - # gzipped or regular files. - if $(${GZCMP} "${1}" "${2}"* >/dev/null 2>&1) ; then - echo "${2}"* - return 1 - elif [[ -e "${2%.gz}" ]] ; then - echo "${2%.gz}" - return 2 - elif [[ -e "${2%.gz}.gz" ]] ; then - echo "${2%.gz}.gz" - return 2 - else - # - # A PPD file doesn't exist in the destination - # repository under the destination label. - # Just display the source PPD file, ensuring - # it has a gzip extension as we will always - # try to gzip the copy in the destination. - # - if [[ "${1#*.ppd}" = ".gz" ]] ; then - echo "${2}" - else - echo "${2}.gz" - fi - return 0 - fi -} - -# -# $1 - Directory mode -# $2 - Directory owner (i.e., root:lp) -# $3 - Directory to create -# -make_dir() -{ - if debugger "make_dir" ; then - set -x - fi - - [[ ! -d "${3}" ]] || return 0 - /bin/mkdir "${3}" >/dev/null 2>&1 || return 1 - set_perms ${1} ${2} "${3}" - return 0 -} - -# -# Remove a ppdmgr generated cache (in /var/lp/ppd/cache) -# if it doesn't have an associated label in the repository. -# -# $1 - Full path to label -# $2 - Cache name -# -remove_unassociated_cache() -{ - if debugger "remove_unassociated_cache" ; then - set -x - fi - - if [[ "${1}" != "${UNSET}" ]] ; then - if [[ -n "${1}" && ! -d "${1}" ]] ; then - # - # The label doesn't exist, so delete - # the associated cache file. - # - /bin/rm -f "${VARCACHES}/${2}" >/dev/null 2>&1 - fi - fi -} - -# -# Sorted copies of cache files for each label in each PPD repository -# are maintained in /var/lp/ppd/caches/<PPD respository>-<label>. -# This is done so that changes in delivered cache files can be -# detected. If a difference in cache files is detected, or a -# cache file is either added or removed, then we know that -# the ppdcache file needs to be updated. -# -# Get a list of all cache files and compare against the list -# of labels in all of the PPD file repositories. They should -# be the same. If there is a label in one of the PPD file -# repositories that doesn't have an associated cache file, then -# we don't worry about it now, as that will be resolved when -# we update the cache for that label. However, if there is -# a cache file associated with a label that no longer exists, then -# remove the cache file. -# -# $1 - Full path to repository (or "all") -# $2 - Label name -# -update_cache() -{ - if debugger ; then - set -x - fi - - # - # Determine which labels in which PPD repository the - # cache file will be updated for. - # - if [[ "${1}" = "all" ]] ; then - rname="${REPOSITORIES}" - else - rname="${1}" - fi - - uc_rc=0 - for dstreppath in ${rname} ; do - labellist= - if [[ "${2}" = "all" ]] ; then - dstrepname=$(get_rep_name "${dstreppath}") - labellist=$(get_rep_label_list "${dstreppath}" \ - "${dstrepname}") - else - - # Ensure the label exists in the PPD file repository. - if [[ -d "${dstreppath}/${2}" ]] ; then - labellist="${2}" - fi - fi - - # - # Update the cache for each label in the PPD repository - # - for dstlabel in ${labellist} ; do - ulc_msg=$(update_label_cache "${dstreppath}" \ - "${dstrepname}" "${dstlabel}") - if [[ $? -ne 0 ]] ; then - echo "${ulc_msg}" - uc_rc=1 - fi - done - done - - # Update the golden cache file. - update_golden_cache - return ${uc_rc} -} - -# $1 - exit status -ppdmgr_exit() -{ - if debugger "ppdmgr_exit" ; then - set -x - fi - - /bin/rm -rf "${ppdmgrtmpdir}" >/dev/null 2>&1 - exit ${1} -} - - -usage() -{ - gettext "usage:\n" 1>&2 - print -n "\t$myprog: " 1>&2 - gettext "-a <ppd_filename_path> [ -L <label> ]\n" 1>&2 - gettext "\t\t[ -R <ppd_repository> ] [-w]\n" 1>&2 - print -n "\t$myprog: " 1>&2 - gettext "-r [ -L <label> ] [ -R <ppd_repository> ]\n" 1>&2 - print -n "\t$myprog: " 1>&2 - gettext "-u [ -L <label> ] [ -R <ppd_repository> ]\n" 1>&2 - - ppdmgr_exit ${FAIL} -} - -########################################################################## -# main -########################################################################## - -myprog=$(/bin/basename $0) - -SaveIFS="$IFS" -NoSpaceTabIFS=' -' - -# Updatable PPD repository -VARDIR=/var/lp/ppd - -# Delivered PPD respository -SYSTEMREP=/usr/share/ppd -ADMINREP=/usr/local/share/ppd -VENDORREP=/opt/share/ppd -USERREP=${VARDIR} - -RESERVEDREPS="${SYSTEMREP} ${ADMINREP} ${VENDORREP}" -REPOSITORIES="${USERREP} ${RESERVEDREPS}" -RESERVEDLABELS="all caches ppdcache manufaliases" - -# Directory where system:SUNWfoomatic is delivered -FOOCACHEDIR=/usr/lib/lp/caches - -# Deliveries -SYSTEM=system -VENDOR=vendor -ADMIN=admin -USER=user - -# Sytem PPD cache name used by printmgr -GOLDCACHE=${USERREP}/ppdcache - -# Delivered caches directory -CACHES=caches -MANUFALIASES=manufaliases - -# Updated caches directory -VARCACHES=${VARDIR}/${CACHES} - -# valid PPD file name extensions -PEXT=ppd -GEXT=gz -FILEEXTS=".${PEXT} .${PEXT}.${GEXT}" - -# Default modes and owners -DIRMODE=755 -DIROWNER=root:lp -ADMINOWNER=root:root -FILEMODE=444 -FILEOWNER=root:lp - -# ppdmgr actions -ADD=add -GENERATEENTRY=generateentry -UPDATE=update -REBUILD=rebuild - -SUCCESS=0 -FAIL=1 -WARN=2 - -MAXLABELNAME=256 -GZIP="/bin/gzip -c" -GZCMP="/bin/gzcmp -s" -CMP="/bin/cmp -s" -SPECIALCHARS=":" -SEP=":" - -debug=0 -wflag=0 -status=${SUCCESS} - -UNSET="" -ppdlabel=${UNSET} -ppdrepname=${UNSET} -ppdreppath=${UNSET} -modmanuf= -model= -nickn= -devidmdl= -devidmfg= - -ppdmgrtmpdir=$(/usr/bin/mktemp -t -d ppdmgr.XXXXXX) -if [ -z "$ppdmgrtmpdir" ] ; then - print -n "$myprog: " 1>&2 - gettext "Fatal error: could not create temporary directory\n" 1>&2 - exit 1 -fi - -aliasfile=${USERREP}/manufaliases -tmpfilepath= - - -OPTS=a:g:L:rR:uwZ -while getopts "$OPTS" arg ; do - case ${arg} in - a) # add PPD file - action=${ADD} - origsrcppdpath=${OPTARG} - ;; - - g) # create cache entry - action=${GENERATEENTRY} - origsrcppdpath=${OPTARG} - ;; - - L) # PPD label name - ppdlabel=${OPTARG} - ;; - - r) # rebuild cache - action=${REBUILD} - ;; - - R) # PPD file repository to use - ppdrepname=${OPTARG} - ;; - - u) # update cache - action=${UPDATE} - ;; - - w) # display PPD file path - wflag=1 - ;; - - Z) # debug - debug=1 - ;; - - ?) - usage - ;; - esac -done - -if debugger "Main" ; then - set -x -fi - -if [[ $# -lt 1 || -z "${action}" ]] ; then - usage -fi - -# ignore wflag unless specified with -a -if [[ ${wflag} -eq 1 && "${action}" != ${ADD} ]] ; then - wflag=0 -fi - -# -# Ensure the destination PPD repository directory is set -# to match the specified repository. If the -# destination PPD file repository was specified, then -# it must be one of the following: -# "user" -# "admin" -# "vendor" -# "system" -# "all" -# -case "${ppdrepname}" in -"${SYSTEM}") - ppdreppath="${SYSTEMREP}" - ;; -"${ADMIN}") - ppdreppath="${ADMINREP}" - ;; -"${VENDOR}") - ppdreppath="${VENDORREP}" - ;; -"${USER}") - ppdreppath="${USERREP}" - ;; -"all") - if [[ "${action}" = "${ADD}" || \ - "${action}" = "${GENERATEENTRY}" ]] ; then - print -n "$myprog: " 1>&2 - gettext "reserved PPD repository name: " 1>&2 - gettext "${ppdrepname}\n" 1>&2 - ppdmgr_exit ${FAIL} - fi - ppdreppath="all" - ;; -"${UNSET}"|"") - ppdreppath="${UNSET}" - ;; - -*) - print -n "$myprog: " 1>&2 - gettext "invalid PPD repository name: ${ppdrepname}\n" 1>&2 - ppdmgr_exit ${FAIL} - ;; -esac - -# -# When a source PPD file's path is from a known repository, the -# destination repository and desination label are assumed to be the -# same as the source PPD file's unless a differing repository or label -# was specified. -# -if [[ "${action}" = "${ADD}" || "${action}" = "${GENERATEENTRY}" ]] ; then - - srcppdpath=$(ppd_pathname "${origsrcppdpath}") - ppd_pathname_rc=$? - if [[ ${ppd_pathname_rc} -ne 0 ]] ; then - print -n "$myprog: " 1>&2 - gettext "invalid PPD file: ${origsrcppdpath}\n" 1>&2 - ppdmgr_exit ${ppd_pathname_rc} - fi - - # Path cannot contain special characters - echo "${srcppdpath}" | /bin/egrep "${SPECIALCHARS}" >/dev/null - if [[ $? -eq 0 ]] ; then - print -n "$myprog: " 1>&2 - gettext "PPD path contains " 1>&2 - gettext "an invalid character: ${ppd_pathname}\n" 1>&2 - ppdmgr_exit ${FAIL} - fi - ppdfname=$(/bin/basename "${origsrcppdpath}") - - # - # Check to see if there's any work to be done. If the source file - # is already in the destination repository under the destination - # label, then there's nothing left to do. We exit rather than - # going on to do an update on the label in the repository as - # it could possible take a long time to update. If an add was - # requested, it could have come from an application, so we want - # to return quickly. - # - if label_path_match "${srcppdpath}" "${ppdreppath}" "${ppdlabel}" ; then - if [[ ${wflag} -eq 1 || \ - "${action}" = "${GENERATEENTRY}" ]] ; then - echo "${srcppdpath}" - fi - ppdmgr_exit ${SUCCESS} - fi -fi - -ppdlabel=$(valid_specified_label "${ppdlabel}") -if [[ $? -ne 0 ]] ; then - ppdmgr_exit ${FAIL} -fi - -if [[ "${ppdreppath}" = "${UNSET}" ]] ; then - ppdreppath="${USERREP}" -fi - -dstrepname=$(get_rep_name "${ppdreppath}") - -case "${action}" in -"${ADD}") - # - # Attempt to add the PPD file to the repository under the - # specified label. If any errors occur, final_dst_ppd_path - # will contain the error message rather than the path to the - # PPD file. - # - final_dst_ppd_path=$(add_ppd "${srcppdpath}" "${ppdfname}" \ - "${ppdreppath}" "${dstrepname}" "${ppdlabel}") - add_ppd_rc=$? - case ${add_ppd_rc} in - 0) # - # The PPD file was added. Update the specified - # cache associated with the label if the PPD file - # was added successfully and was not a duplicate. - # Ensure any changes are also reflected in the - # golden cache. - # - add_ppd_msg=$(update_label_cache "${ppdreppath}" \ - "${dstrepname}" "${ppdlabel}") - apm_rc=$? - - echo "${add_ppd_msg}" | /bin/grep "${final_dst_ppd_path}" - path_in_msg=$? - - # - # Only report cache update errors if the file that was - # added was one that was reported as not being added - # to the cache. This really should happen as the file - # was verified during the add. - # - if [[ ${apm_rc} -ne 0 && ${path_in_msg} -eq 0 ]] ; then - print -n "$myprog: " 1>&2 - gettext "printer information does not reflect " 1>&2 - gettext "the\nfollowing PPD file(s):\n" 1>&2 - print "${add_ppd_msg}" 1>&2 - status=${FAIL} - else - update_golden_cache - - # - # Display the full path to the added PPD file, - # if requested (-w). - # - if [[ ${wflag} -eq 1 ]] ; then - print "${final_dst_ppd_path}" - fi - fi - ;; - - 1) # Duplicate copy exists - if [[ ${wflag} -eq 1 ]] ; then - print "${final_dst_ppd_path}" - fi - ;; - - 2) # Varying copy exists - print -n "$myprog: " 1>&2 - gettext "differing variant of source PPD file " 1>&2 - gettext "already exists at\n" 1>&2 - gettext "${final_dst_ppd_path}\n" 1>&2 - status=${FAIL} - ;; - *) # The PPD file was not added as a problem occurred. - # Display the error message. - print -n "$myprog: " 1>&2 - print "${final_dst_ppd_path}" 1>&2 - status=${FAIL} - ;; - - esac - ;; - -"${GENERATEENTRY}") - # - # Create a cache file entry for the specified PPD file and - # display it on standard out. - # - verify_ppd_file "${srcppdpath}" - if [[ $? -eq 0 ]] ; then - dstdir="${ppdreppath}/${ppdlabel}/${modmanuf}" - final_dst_path="${dstdir}/$(/bin/basename ${srcppdpath})" - verify_ppd_location "${final_dst_path}" - if [[ $? -eq 0 ]] ; then - # Generate the cache file entry - print "$(generate_cache_file_entry "${modmanuf}" \ - "${model}" "${nickn}" "${devidmfg}" "${devidmdl}" \ - "${final_dst_path}")" - else - print -n "$myprog: " 1>&2 - gettext "PPD file not in valid location\n" 1>&2 - gettext \ - "(<repository>/<label>/<manufacturer>/<PPD file>):\n\t${1}\n" 1>&2 - status=${FAIL} - fi - - else - print -n "$myprog: " 1>&2 - gettext "invalid PPD file: ${1}\n" 1>&2 - status=${FAIL} - fi - ;; - -"${REBUILD}" | "${UPDATE}") - update_msg=$(update_cache "${ppdreppath}" "${ppdlabel}") - if [[ $? -ne 0 ]] ; then - print -n "$myprog: " 1>&2 - gettext "printer information does not reflect " 1>&2 - gettext "the\nfollowing PPD file(s):\n" 1>&2 - print "${update_msg}" 1>&2 - status=${WARN} - fi - ;; - -*) - usage - ;; -esac - -ppdmgr_exit ${status} diff --git a/usr/src/cmd/print/scripts/printers.conf b/usr/src/cmd/print/scripts/printers.conf deleted file mode 100644 index 69327e9915..0000000000 --- a/usr/src/cmd/print/scripts/printers.conf +++ /dev/null @@ -1,31 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 1996 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" - -# -# If you hand edit this file, comments and structure may change. -# The prefered method of modifying this file is though the use of -# lpset(1M) or lpadmin(1M) -# diff --git a/usr/src/cmd/print/selector/Makefile b/usr/src/cmd/print/selector/Makefile deleted file mode 100644 index 9cd5704869..0000000000 --- a/usr/src/cmd/print/selector/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -include ../../Makefile.cmd - -SBINPROG = print-service -BINPROG = desktop-print-management-applet -LPBINLINKS = lp lpstat cancel enable disable -LPRBINLINKS = lpr lpq lprm lpc -DESKTOPLINKS = desktop-print-management desktop-print-management-prefs -BINLINKS = $(LPBINLINKS) $(LPRBINLINKS) $(DESKTOPLINKS) -SBINLINKS = accept reject lpmove lpadmin - -ROOTUSRSBINPROG = $(SBINPROG:%=$(ROOTUSRSBIN)/%) -ROOTUSRBINPROG = $(BINPROG:%=$(ROOTBIN)/%) -ROOTUSRBINLINKS = $(BINLINKS:%=$(ROOTBIN)/%) -ROOTUSRSBINLINKS = $(SBINLINKS:%=$(ROOTUSRSBIN)/%) - -FILEMODE = 0555 - -$(ROOTUSRBINLINKS): - $(RM) $@; $(SYMLINK) ../sbin/$(SBINPROG) $@ - -$(ROOTUSRSBINLINKS): - $(RM) $@; $(SYMLINK) $(SBINPROG) $@ - -.KEEP_STATE: - -all check clean clobber lint: - -install: $(ROOTUSRSBINPROG) $(ROOTUSRBINPROG) $(ROOTUSRBINLINKS) $(ROOTUSRSBINLINKS) - diff --git a/usr/src/cmd/print/selector/desktop-print-management-applet b/usr/src/cmd/print/selector/desktop-print-management-applet deleted file mode 100755 index 88dd74799d..0000000000 --- a/usr/src/cmd/print/selector/desktop-print-management-applet +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/perl5/bin/perl -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# -use Errno qw(EINTR :POSIX); - -my $SVC_CUPS_SCHEDULER = 'cups/scheduler'; -my $SVCPROP = '/usr/bin/svcprop'; -my $reexec = 0; - -sub svcprop { - local ($fmri, $property) = @_; - my $FH; - - open($FH, "$SVCPROP -C -p $property $fmri 2>/dev/null |"); - $result = <$FH>; - close($FH); - - return ($result); -} - -sub print_service { - my $service; - - $service = svcprop("$SVC_CUPS_SCHEDULER:default", "general/active"); - ($service =~ /true/) && ($service = 'cups') || ($service = 'lp'); - - return ($service); -} - -sub kill_running_applets { - $reexec = 1; - # cups applet daemon - system("pkill -f '/system-config-printer/applet.py'"); - # lp applet daemon - system("pkill ospm-applet"); -} - -sub handle_signal { - kill_running_applets (); -} - -$SIG{USR1} = \&handle_signal; - -my $pid = fork(); -if (! defined($pid)) { - die "Error: fork() failed\n"; -} -elsif ($pid == 0) { - my $service = print_service(); - if ($service eq 'lp') { - exec('/usr/lib/lp/bin/desktop-print-management-applet'); - } - else { - exec('/usr/lib/cups/bin/desktop-print-management-applet'); - } - -} -else { - my $retid; - while ((($retid = waitpid($pid, 0)) < 0) && $!{EINTR}) { - } - - if ($retid == $pid && $reexec) { - exec('/usr/bin/desktop-print-management-applet'); - } -} - -exit(0); diff --git a/usr/src/cmd/print/selector/print-service b/usr/src/cmd/print/selector/print-service deleted file mode 100755 index 7f90256aac..0000000000 --- a/usr/src/cmd/print/selector/print-service +++ /dev/null @@ -1,298 +0,0 @@ -#!/usr/perl5/bin/perl -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# This program manages the "active" print service selection. -# If called as 'print-service', it takes one of four options. -# Options: -# [-s[et] service [-m]] Select the "active" print service, optionally -# migrating basic print queue configuration. -# [-q[uery]] Display the "active" print service. -# [-e[xport] file] Export basic print queue configuration to -# a file. -# [-i[mport] file] Import basic print queue configuration from -# a file. -# -# If called by any other name, it will look for a corresponding command -# under /usr/lib/{active-service}/bin/{command} and execute that program -# with the original arguments. -# - -use Getopt::Long; -use File::Basename; -use File::Copy; -use File::Temp qw/ :POSIX /; - -my $cmd = basename($0); - -my $LPSTAT = '/usr/bin/lpstat'; -my $LPADMIN = '/usr/sbin/lpadmin'; -my $ENABLE = '/usr/bin/enable'; -my $ACCEPT = '/usr/sbin/accept'; -my $SVCADM = '/usr/sbin/svcadm'; -my $SVCPROP = '/usr/bin/svcprop'; -my $SVCCFG = '/usr/sbin/svccfg'; -my $SVC_LP_SCHEDULER = 'print/server'; -my $SVC_LP_LPD = 'print/rfc1179'; -my $SVC_LP_IPP = 'print/ipp-listener'; -my $SVC_LP_PPD = 'print/ppd-cache-update'; -my $SVC_CUPS_SCHEDULER = 'cups/scheduler'; -my $SVC_CUPS_LPD = 'cups/in-lpd'; - -sub fatal { - ($ENV{"DESKTOP_LAUNCHED"}) && - exec("/bin/zenity", "--error", "--text=@_"); - print STDERR @_; - exit(1); -} - -sub usage { - print STDERR <<EOF ; -Usage: - $cmd [-s[et] service [-m]] Select the \"active\" print service, - optionally migrating basic print queue - configuration. - $cmd [-q[uery]] Display the "active" print service. - $cmd [-e[xport] file] Export basic print queue configuration - to a file. - $cmd [-i[mport] file] Import basic print queue configuration - from a file. -EOF - exit(1); -} - -sub svcprop { - local ($fmri, $property) = @_; - my $FH; - - open($FH, "$SVCPROP -C -p $property $fmri 2>/dev/null |"); - $result = <$FH>; - close($FH); - - return ($result); -} - -sub svccfg { - local ($fmri, $operation) = @_; - my $FH; - - open($FH, "$SVCCFG -s $fmri \"$operation\" 2>/dev/null |"); - $result = <$FH>; - close($FH); - - return ($result); -} - -sub svcadm { - local ($operation, @fmris) = @_; - - system("$SVCADM $operation -s @fmris"); -} - - -sub print_service { - my $service; - - $service = svcprop("$SVC_CUPS_SCHEDULER:default", "general/active"); - ($service =~ /true/) && ($service = 'cups') || ($service = 'lp'); - - return ($service); -} - -sub print_command { - local($command, @av) = @_; - my $service = print_service(); - - if (!defined($service)) { - fatal("failed to detect active print service: $!\n"); - } - - if (! -d "/usr/lib/$service/bin") { - fatal("print service: $service is not installed\n"); - } - - my $executable = "/usr/lib/$service/bin/$command"; - # CUPS has it's own names for enable and disable - ($command =~ /(en|dis)able/) && ($service eq 'cups') && - (! -x $executable) && - ($executable = "/usr/lib/$service/bin/$service$command"); - - if (! -x $executable) { - fatal("$command is not available from $service print service\n"); - } - - exec($executable, @ARGV); -} - -sub export_print_queues { - local ($path) = @_; - my $service = print_service(); - - if ($service eq 'lp') { - my $FH, $DFH; - - open($FH, ">$path"); - open($DFH, "$LPSTAT -v|"); - while (<$DFH>) { - if (/device for (.+): (.+)/) { - my $EFH; - - print $FH "<Printer $1>\nDeviceURI $2\n"; - open($EFH, "$LPSTAT -p $1 -l |"); - while (<$EFH>) { - (/Description: (.+)/) && - print $FH "Info $1\n"; - } - close($EFH); - print $FH "</Printer>\n"; - } - } - close($DFH); - close($FH); - } else { - copy('/etc/cups/printers.conf', $path); - } -} - -sub psystem { - print " @_\n"; - system(@_); -} - -sub import_print_queues { - local ($path) = @_; - my $service = print_service(); - my $FH, %printer, @options; - - # store queue info in the 'active' print service - open($FH, "<$path"); - while (<$FH>) { - if (/<Printer (.+)>/) { - $printer{'Printer'} = $1; - @options = (); - push(@options, "-p", $1); - } elsif (/([^\s]+)\s(.+)/) { - $printer{$1} = $2; - my $value = $2; - ($1 eq 'DeviceURI') && - push(@options, "-v", $value); - ($1 eq 'Info') && - push(@options, "-D", $value); - } elsif (/<\/Printer>/) { - ($service eq 'lp') && - push(@options, "-m", "uri"); - print "importing $printer{'Printer'}...\n"; - # create a queue - psystem($LPADMIN, @options); - psystem($ENABLE, $printer{'Printer'}); - ($printer{'Accepting'} eq 'Yes') && - psystem($ACCEPT, $printer{'Printer'}); - $printer = (); - } - } - close($FH); -} - -sub select_service { - my ($service, $migrate) = @_; - my $FH, $queues; - - if (! -d "/usr/lib/$service/bin") { - fatal("print service: $service is not installed\n"); - } - - if ($migrate == 1) { - # export old print queue configuration (if migrating) - $queues = tmpnam(); - export_print_queues($queues); - } - - # enable/disable the services - if ($service eq 'cups') { - (-f '/etc/printers.conf') && (! -f '/etc/lp/printers.conf') && - rename('/etc/printers.conf', '/etc/lp/printers.conf'); - print("disabling LP services...\n"); - svcadm("disable", $SVC_LP_SCHEDULER, $SVC_LP_IPP, $SVC_LP_LPD, - $SVC_LP_PPD); - print("enabling CUPS services...\n"); - svcadm("enable", $SVC_CUPS_SCHEDULER, $SVC_CUPS_LPD); - svccfg("cups/scheduler:default", - "setprop general/active = boolean: true"); - system("pkill -USR1 -f '/desktop-print-management-applet'"); - } else { - print("disabling CUPS services...\n"); - svcadm("disable", $SVC_CUPS_SCHEDULER, $SVC_CUPS_LPD); - print("enabling LP services...\n"); - svcadm("enable", $SVC_LP_SCHEDULER, $SVC_LP_IPP, $SVC_LP_LPD, - $SVC_LP_PPD); - (-f '/etc/lp/printers.conf') && - rename('/etc/lp/printers.conf', '/etc/printers.conf'); - svccfg("cups/scheduler:default", "delprop general/active"); - system("pkill -USR1 -f '/desktop-print-management-applet'"); - } - - # import the new print queue configuration (if migrating) - defined($queues) && import_print_queues($queues); -} - -sub query_service { - my $service = print_service(); - - if (!defined($service)) { - fatal("failed to detect active print service: $!\n"); - } - print "active print service: $service\n"; -} - -if ($cmd eq 'print-service') { - my ($import_path, $export_path, $svc_name, $query, $migrate) = (); - - my $res = GetOptions('q|query' => \$query, 's|set=s' => \$service, - 'm|migrate' => \$migrate, 'e|export=s' => \$export_path, - 'i|import=s' => \$import_path); - - ($res) || usage(); - - if (defined($import_path) && !defined($export_path) && - !defined($query) && !defined($service) && !defined($migrate)) { - import_print_queues($import_path); - } elsif (!defined($import_path) && defined($export_path) && - !defined($query) && !defined($service) && !defined($migrate)) { - export_print_queues($export_path); - } elsif (!defined($import_path) && !defined($export_path) && - defined($query) && !defined($service) && !defined($migrate)) { - query_service(); - } elsif (!defined($import_path) && !defined($export_path) && - !defined($query) && defined($service)) { - select_service($service, $migrate); - } else { - usage(); - } -} else { - print_command($cmd, @ARGV); -} - -exit(0); |