< prev index next >

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

Print this page




   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
  23  * questions.
  24  */
  25 
  26 package sun.print;
  27 
  28 import sun.misc.ManagedLocalsThread;
  29 
  30 import java.io.BufferedReader;
  31 import java.io.FileInputStream;
  32 import java.io.InputStream;
  33 import java.io.InputStreamReader;
  34 import java.io.IOException;
  35 import java.util.ArrayList;
  36 import java.util.Vector;
  37 import java.security.AccessController;
  38 import java.security.PrivilegedActionException;
  39 import java.security.PrivilegedExceptionAction;
  40 import javax.print.DocFlavor;
  41 import javax.print.MultiDocPrintService;
  42 import javax.print.PrintService;
  43 import javax.print.PrintServiceLookup;
  44 import javax.print.attribute.Attribute;
  45 import javax.print.attribute.AttributeSet;
  46 import javax.print.attribute.HashPrintRequestAttributeSet;
  47 import javax.print.attribute.HashPrintServiceAttributeSet;
  48 import javax.print.attribute.PrintRequestAttribute;
  49 import javax.print.attribute.PrintRequestAttributeSet;


 196         String command  = "/usr/sbin/lpc status all";
 197         String[] names = execCmd(command);
 198 
 199         if ((names == null) || (names.length == 0)) {
 200             return BSD_LPD_NG;
 201         }
 202 
 203         for (int i=0; i<names.length; i++) {
 204             if (names[i].indexOf('@') != -1) {
 205                 return BSD_LPD_NG;
 206             }
 207         }
 208 
 209         return BSD_LPD;
 210     }
 211 
 212 
 213     public PrintServiceLookupProvider() {
 214         // start the printer listener thread
 215         if (pollServices) {
 216             Thread thr = new ManagedLocalsThread(new PrinterChangeListener());

 217             thr.setDaemon(true);
 218             thr.start();
 219             IPPPrintService.debug_println(debugPrefix+"polling turned on");
 220         }
 221     }
 222 
 223     /* Want the PrintService which is default print service to have
 224      * equality of reference with the equivalent in list of print services
 225      * This isn't required by the API and there's a risk doing this will
 226      * lead people to assume its guaranteed.
 227      */
 228     public synchronized PrintService[] getPrintServices() {
 229         SecurityManager security = System.getSecurityManager();
 230         if (security != null) {
 231             security.checkPrintJobAccess();
 232         }
 233 
 234         if (printServices == null || !pollServices) {
 235             refreshServices();
 236         }




   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
  23  * questions.
  24  */
  25 
  26 package sun.print;
  27 


  28 import java.io.BufferedReader;
  29 import java.io.FileInputStream;
  30 import java.io.InputStream;
  31 import java.io.InputStreamReader;
  32 import java.io.IOException;
  33 import java.util.ArrayList;
  34 import java.util.Vector;
  35 import java.security.AccessController;
  36 import java.security.PrivilegedActionException;
  37 import java.security.PrivilegedExceptionAction;
  38 import javax.print.DocFlavor;
  39 import javax.print.MultiDocPrintService;
  40 import javax.print.PrintService;
  41 import javax.print.PrintServiceLookup;
  42 import javax.print.attribute.Attribute;
  43 import javax.print.attribute.AttributeSet;
  44 import javax.print.attribute.HashPrintRequestAttributeSet;
  45 import javax.print.attribute.HashPrintServiceAttributeSet;
  46 import javax.print.attribute.PrintRequestAttribute;
  47 import javax.print.attribute.PrintRequestAttributeSet;


 194         String command  = "/usr/sbin/lpc status all";
 195         String[] names = execCmd(command);
 196 
 197         if ((names == null) || (names.length == 0)) {
 198             return BSD_LPD_NG;
 199         }
 200 
 201         for (int i=0; i<names.length; i++) {
 202             if (names[i].indexOf('@') != -1) {
 203                 return BSD_LPD_NG;
 204             }
 205         }
 206 
 207         return BSD_LPD;
 208     }
 209 
 210 
 211     public PrintServiceLookupProvider() {
 212         // start the printer listener thread
 213         if (pollServices) {
 214             Thread thr = new Thread(null, new PrinterChangeListener(),
 215                                     "PrinterListener", 0, false);
 216             thr.setDaemon(true);
 217             thr.start();
 218             IPPPrintService.debug_println(debugPrefix+"polling turned on");
 219         }
 220     }
 221 
 222     /* Want the PrintService which is default print service to have
 223      * equality of reference with the equivalent in list of print services
 224      * This isn't required by the API and there's a risk doing this will
 225      * lead people to assume its guaranteed.
 226      */
 227     public synchronized PrintService[] getPrintServices() {
 228         SecurityManager security = System.getSecurityManager();
 229         if (security != null) {
 230             security.checkPrintJobAccess();
 231         }
 232 
 233         if (printServices == null || !pollServices) {
 234             refreshServices();
 235         }


< prev index next >