equal
deleted
inserted
replaced
44 import javax.print.attribute.EnumSyntax; |
44 import javax.print.attribute.EnumSyntax; |
45 import javax.print.attribute.standard.PrinterName; |
45 import javax.print.attribute.standard.PrinterName; |
46 |
46 |
47 |
47 |
48 public class CUPSPrinter { |
48 public class CUPSPrinter { |
49 |
49 private static final String debugPrefix = "CUPSPrinter>> "; |
50 private static final double PRINTER_DPI = 72.0; |
50 private static final double PRINTER_DPI = 72.0; |
51 private static boolean initialized; |
51 private boolean initialized; |
52 private static native String getCupsServer(); |
52 private static native String getCupsServer(); |
53 private static native int getCupsPort(); |
53 private static native int getCupsPort(); |
54 private static native boolean canConnect(String server, int port); |
54 private static native boolean canConnect(String server, int port); |
55 private static native boolean initIDs(); |
55 private static native boolean initIDs(); |
56 // These functions need to be synchronized as |
56 // These functions need to be synchronized as |
154 |
154 |
155 |
155 |
156 /** |
156 /** |
157 * Initialize media by translating PPD info to PrintService attributes. |
157 * Initialize media by translating PPD info to PrintService attributes. |
158 */ |
158 */ |
159 private void initMedia() { |
159 private synchronized void initMedia() { |
160 if (initialized) { |
160 if (initialized) { |
161 return; |
161 return; |
162 } else { |
162 } else { |
163 initialized = true; |
163 initialized = true; |
164 } |
164 } |
390 |
390 |
391 /** |
391 /** |
392 * Detects if CUPS is running. |
392 * Detects if CUPS is running. |
393 */ |
393 */ |
394 public static boolean isCupsRunning() { |
394 public static boolean isCupsRunning() { |
395 IPPPrintService.debug_println("libFound "+libFound); |
395 IPPPrintService.debug_println(debugPrefix+"libFound "+libFound); |
396 if (libFound) { |
396 if (libFound) { |
397 IPPPrintService.debug_println("CUPS server "+getServer()+ |
397 IPPPrintService.debug_println(debugPrefix+"CUPS server "+getServer()+ |
398 " port "+getPort()); |
398 " port "+getPort()); |
399 return canConnect(getServer(), getPort()); |
399 return canConnect(getServer(), getPort()); |
400 } else { |
400 } else { |
401 return false; |
401 return false; |
402 } |
402 } |