< prev index next >

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

Print this page

        

*** 401,417 **** Hence an alternative mechanism is choosen via the EnumPrinters by polling for the count of printer status changes(add\remove) and based on it update the printers list. */ class RemotePrinterChangeListener implements Runnable { ! private String[] prevRemotePrinters; RemotePrinterChangeListener() { prevRemotePrinters = getRemotePrintersNames(); } boolean doCompare(String[] str1, String[] str2) { if (str1.length != str2.length) { return true; } else { for (int i = 0;i < str1.length;i++) { for (int j = 0;j < str2.length;j++) { --- 401,423 ---- Hence an alternative mechanism is choosen via the EnumPrinters by polling for the count of printer status changes(add\remove) and based on it update the printers list. */ class RemotePrinterChangeListener implements Runnable { ! private String[] prevRemotePrinters = null; RemotePrinterChangeListener() { prevRemotePrinters = getRemotePrintersNames(); } boolean doCompare(String[] str1, String[] str2) { + if (str1 == null && str2 == null) { + return false; + } else if ((str1 == null && str2 != null) || (str2 == null && str1 != null)) { + return true; + } + if (str1.length != str2.length) { return true; } else { for (int i = 0;i < str1.length;i++) { for (int j = 0;j < str2.length;j++) {
*** 426,445 **** --- 432,455 ---- } @Override public void run() { while (true) { + if (prevRemotePrinters != null) { String[] currentRemotePrinters = getRemotePrintersNames(); if (doCompare(prevRemotePrinters, currentRemotePrinters)) { // updated the printers data // printers list now contains both local and network printer data refreshServices(); // store the current data for next comparison prevRemotePrinters = currentRemotePrinters; } + } else { + prevRemotePrinters = getRemotePrintersNames(); + } try { Thread.sleep(minRefreshTime * 1000); } catch (InterruptedException e) { break;
< prev index next >