jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
changeset 542 eb75700cdf75
parent 2 90ce3da70b43
child 715 f16baef3a20e
equal deleted inserted replaced
536:a29f1f8c0983 542:eb75700cdf75
   194     }
   194     }
   195 
   195 
   196 
   196 
   197     // refreshes "printServices"
   197     // refreshes "printServices"
   198     public synchronized void refreshServices() {
   198     public synchronized void refreshServices() {
   199         String[] printers; /* excludes the default printer */
   199         /* excludes the default printer */
       
   200         String[] printers = null; // array of printer names
       
   201         String[] printerURIs = null; //array of printer URIs
   200 
   202 
   201         getDefaultPrintService();
   203         getDefaultPrintService();
   202         if (CUPSPrinter.isCupsRunning()) {
   204         if (CUPSPrinter.isCupsRunning()) {
   203             printers = CUPSPrinter.getAllPrinters();
   205             printerURIs = CUPSPrinter.getAllPrinters();
       
   206             if ((printerURIs != null) && (printerURIs.length > 0)) {
       
   207                 printers = new String[printerURIs.length];
       
   208                 for (int i=0; i<printerURIs.length; i++) {
       
   209                     int lastIndex = printerURIs[i].lastIndexOf("/");
       
   210                     printers[i] = printerURIs[i].substring(lastIndex+1);
       
   211                 }
       
   212             }
   204         } else {
   213         } else {
   205             if (isSysV()) {
   214             if (isSysV()) {
   206                 printers = getAllPrinterNamesSysV();
   215                 printers = getAllPrinterNamesSysV();
   207             } else { //BSD
   216             } else { //BSD
   208                 printers = getAllPrinterNamesBSD();
   217                 printers = getAllPrinterNamesBSD();
   234                     IPPPrintService.debug_println(debugPrefix+
   243                     IPPPrintService.debug_println(debugPrefix+
   235                                                   "total# of printers = "+printers.length);
   244                                                   "total# of printers = "+printers.length);
   236 
   245 
   237                     if (CUPSPrinter.isCupsRunning()) {
   246                     if (CUPSPrinter.isCupsRunning()) {
   238                         try {
   247                         try {
   239                             URL serviceURL =
   248                             printerList.add(new IPPPrintService(printers[p],
   240                                 new URL("http://"+
   249                                                                 printerURIs[p],
   241                                         CUPSPrinter.getServer()+":"+
   250                                                                 true));
   242                                         CUPSPrinter.getPort()+"/"+printers[p]);
       
   243                             printerList.add(new IPPPrintService( printers[p],
       
   244                                                                  serviceURL));
       
   245                         } catch (Exception e) {
   251                         } catch (Exception e) {
   246                             IPPPrintService.debug_println(debugPrefix+
   252                             IPPPrintService.debug_println(debugPrefix+
   247                                                           " getAllPrinters Exception "+
   253                                                           " getAllPrinters Exception "+
   248                                                           e);
   254                                                           e);
   249 
   255 
   263                     }
   269                     }
   264 
   270 
   265                     if (j == printServices.length) {      // not found?
   271                     if (j == printServices.length) {      // not found?
   266                         if (CUPSPrinter.isCupsRunning()) {
   272                         if (CUPSPrinter.isCupsRunning()) {
   267                             try {
   273                             try {
   268                                 URL serviceURL =
   274                                 printerList.add(new IPPPrintService(
   269                                     new URL("http://"+
   275                                                                printers[p],
   270                                         CUPSPrinter.getServer()+":"+
   276                                                                printerURIs[p],
   271                                         CUPSPrinter.getPort()+"/"+printers[p]);
   277                                                                true));
   272                                 printerList.add(new IPPPrintService( printers[p],
       
   273                                                                  serviceURL));
       
   274                             } catch (Exception e) {
   278                             } catch (Exception e) {
   275                                 IPPPrintService.debug_println(debugPrefix+
   279                                 IPPPrintService.debug_println(debugPrefix+
   276                                                               " getAllPrinters Exception "+
   280                                                               " getAllPrinters Exception "+
   277                                                               e);
   281                                                               e);
   278 
   282