< prev index next >

src/java.desktop/unix/classes/sun/print/UnixPrintJob.java

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 871         }
 872         if (options != null && !options.isEmpty()) {
 873             pFlags |= OPTIONS;
 874             ncomps+=1;
 875         }
 876         if (jobTitle != null && !jobTitle.isEmpty()) {
 877             pFlags |= JOBTITLE;
 878             ncomps+=1;
 879         }
 880         if (copies > 1) {
 881             pFlags |= COPIES;
 882             ncomps+=1;
 883         }
 884         if (noJobSheet) {
 885             pFlags |= NOSHEET;
 886             ncomps+=1;
 887         } else if (getPrintService().
 888                         isAttributeCategorySupported(JobSheets.class)) {
 889             ncomps+=1;
 890         }
 891         if (PrintServiceLookupProvider.osname.equals("SunOS")) {
 892             ncomps+=1; // lp uses 1 more arg than lpr (make a copy)
 893             execCmd = new String[ncomps];
 894             execCmd[n++] = "/usr/bin/lp";
 895             execCmd[n++] = "-c";           // make a copy of the spool file
 896             if ((pFlags & PRINTER) != 0) {
 897                 execCmd[n++] = "-d" + printer;
 898             }
 899             if ((pFlags & JOBTITLE) != 0) {
 900                 String quoteChar = "\"";
 901                 execCmd[n++] = "-t "  + quoteChar+jobTitle+quoteChar;
 902             }
 903             if ((pFlags & COPIES) != 0) {
 904                 execCmd[n++] = "-n " + copies;
 905             }
 906             if ((pFlags & NOSHEET) != 0) {
 907                 execCmd[n++] = "-o nobanner";
 908             } else if (getPrintService().
 909                         isAttributeCategorySupported(JobSheets.class)) {
 910                 execCmd[n++] = "-o job-sheets=standard";
 911             }
 912             if ((pFlags & OPTIONS) != 0) {
 913                 execCmd[n++] = "-o " + options;
 914             }
 915         } else {
 916             execCmd = new String[ncomps];
 917             execCmd[n++] = "/usr/bin/lpr";
 918             if ((pFlags & PRINTER) != 0) {
 919                 execCmd[n++] = "-P" + printer;
 920             }
 921             if ((pFlags & JOBTITLE) != 0) {
 922                 execCmd[n++] = "-J "  + jobTitle;
 923             }
 924             if ((pFlags & COPIES) != 0) {
 925                 execCmd[n++] = "-#" + copies;
 926             }
 927             if ((pFlags & NOSHEET) != 0) {
 928                 execCmd[n++] = "-h";
 929             } else if (getPrintService().
 930                         isAttributeCategorySupported(JobSheets.class)) {
 931                 execCmd[n++] = "-o job-sheets=standard";
 932             }
 933             if ((pFlags & OPTIONS) != 0) {
 934                 execCmd[n++] = "-o" + options;
 935             }
 936         }
 937         execCmd[n++] = spoolFile;
 938         if (IPPPrintService.debugPrint) {
 939             System.out.println("UnixPrintJob>> execCmd");
 940             for (int i=0; i<execCmd.length; i++) {
 941                 System.out.print(" "+execCmd[i]);
 942             }
 943             System.out.println();
 944         }
 945         return execCmd;
 946     }
 947 
 948     private static int DESTPRINTER = 1;
 949     private static int DESTFILE = 2;
 950     private int mDestType = DESTPRINTER;
 951 
 952     private File spoolFile;
 953     private String mDestination, mOptions="";
 954     private boolean mNoJobSheet = false;
 955 


   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 871         }
 872         if (options != null && !options.isEmpty()) {
 873             pFlags |= OPTIONS;
 874             ncomps+=1;
 875         }
 876         if (jobTitle != null && !jobTitle.isEmpty()) {
 877             pFlags |= JOBTITLE;
 878             ncomps+=1;
 879         }
 880         if (copies > 1) {
 881             pFlags |= COPIES;
 882             ncomps+=1;
 883         }
 884         if (noJobSheet) {
 885             pFlags |= NOSHEET;
 886             ncomps+=1;
 887         } else if (getPrintService().
 888                         isAttributeCategorySupported(JobSheets.class)) {
 889             ncomps+=1;
 890         }

























 891         execCmd = new String[ncomps];
 892         execCmd[n++] = "/usr/bin/lpr";
 893         if ((pFlags & PRINTER) != 0) {
 894             execCmd[n++] = "-P" + printer;
 895         }
 896         if ((pFlags & JOBTITLE) != 0) {
 897             execCmd[n++] = "-J "  + jobTitle;
 898         }
 899         if ((pFlags & COPIES) != 0) {
 900             execCmd[n++] = "-#" + copies;
 901         }
 902         if ((pFlags & NOSHEET) != 0) {
 903             execCmd[n++] = "-h";
 904         } else if (getPrintService().
 905                    isAttributeCategorySupported(JobSheets.class)) {
 906             execCmd[n++] = "-o job-sheets=standard";
 907         }
 908         if ((pFlags & OPTIONS) != 0) {
 909             execCmd[n++] = "-o" + options;

 910         }
 911         execCmd[n++] = spoolFile;
 912         if (IPPPrintService.debugPrint) {
 913             System.out.println("UnixPrintJob>> execCmd");
 914             for (int i=0; i<execCmd.length; i++) {
 915                 System.out.print(" "+execCmd[i]);
 916             }
 917             System.out.println();
 918         }
 919         return execCmd;
 920     }
 921 
 922     private static int DESTPRINTER = 1;
 923     private static int DESTFILE = 2;
 924     private int mDestType = DESTPRINTER;
 925 
 926     private File spoolFile;
 927     private String mDestination, mOptions="";
 928     private boolean mNoJobSheet = false;
 929 


< prev index next >