< prev index next >
src/java.desktop/unix/classes/sun/print/CUPSPrinter.java
Print this page
*** 50,59 ****
--- 50,60 ----
private static final String debugPrefix = "CUPSPrinter>> ";
private static final double PRINTER_DPI = 72.0;
private boolean initialized;
private static native String getCupsServer();
private static native int getCupsPort();
+ private static native String getCupsDefaultPrinter();
private static native boolean canConnect(String server, int port);
private static native boolean initIDs();
// These functions need to be synchronized as
// CUPS does not support multi-threading.
private static synchronized native String[] getMedia(String printer);
*** 264,273 ****
--- 265,283 ----
/**
* Get CUPS default printer using IPP.
* Returns 2 values - index 0 is printer name, index 1 is the uri.
*/
static String[] getDefaultPrinter() {
+ // Try to get user/lpoptions-defined printer name from CUPS
+ // if not user-set, then go for server default destination
+ String printerInfo[] = new String[2];
+ printerInfo[0] = getCupsDefaultPrinter();
+
+ if (printerInfo[0] != null) {
+ printerInfo[1] = null;
+ return printerInfo.clone();
+ }
try {
URL url = new URL("http", getServer(), getPort(), "");
final HttpURLConnection urlConnection =
IPPPrintService.getIPPConnection(url);
*** 299,309 ****
if (IPPPrintService.writeIPPRequest(os,
IPPPrintService.OP_CUPS_GET_DEFAULT,
attCl)) {
HashMap<String, AttributeClass> defaultMap = null;
! String[] printerInfo = new String[2];
InputStream is = urlConnection.getInputStream();
HashMap<String, AttributeClass>[] responseMap = IPPPrintService.readIPPResponse(
is);
is.close();
--- 309,319 ----
if (IPPPrintService.writeIPPRequest(os,
IPPPrintService.OP_CUPS_GET_DEFAULT,
attCl)) {
HashMap<String, AttributeClass> defaultMap = null;
!
InputStream is = urlConnection.getInputStream();
HashMap<String, AttributeClass>[] responseMap = IPPPrintService.readIPPResponse(
is);
is.close();
< prev index next >