< prev index next >

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

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
--- 1,7 ---
  /*
!  * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

*** 454,16 ***
                  // maybe use "&& (usePPD)" later?
                  // Another reason why we use PPD is because
                  // IPP currently does not support it but PPD does.
  
                  try {
!                     cps = new CUPSPrinter(printer);
!                     mediaSizeNames = cps.getMediaSizeNames();
!                     mediaTrays = cps.getMediaTrays();
!                     customMediaSizeNames = cps.getCustomMediaSizeNames();
!                     defaultMediaIndex = cps.getDefaultMediaIndex();
!                     rawResolutions = cps.getRawResolutions();
                      urlConnection.disconnect();
                      init = true;
                      return;
                  } catch (Exception e) {
                      IPPPrintService.debug_println(debugPrefix+
--- 454,18 ---
                  // maybe use "&& (usePPD)" later?
                  // Another reason why we use PPD is because
                  // IPP currently does not support it but PPD does.
  
                  try {
!                     if (cps == null) {
!                         cps = new CUPSPrinter(printer);
!                         mediaSizeNames = cps.getMediaSizeNames();
!                         mediaTrays = cps.getMediaTrays();
!                         customMediaSizeNames = cps.getCustomMediaSizeNames();
!                         defaultMediaIndex = cps.getDefaultMediaIndex();
+                         rawResolutions = cps.getRawResolutions();
+                     }
                      urlConnection.disconnect();
                      init = true;
                      return;
                  } catch (Exception e) {
                      IPPPrintService.debug_println(debugPrefix+

*** 1009,19 ***
  
      /**
       * Returns the matching standard Media using string comparison of names.
       */
      private Media getIPPMedia(String mediaName) {
!         CustomMediaSizeName sampleSize = new CustomMediaSizeName("sample", "",
!                                                                  0, 0);
          Media[] sizes = sampleSize.getSuperEnumTable();
          for (int i=0; i<sizes.length; i++) {
              if (mediaName.equals(""+sizes[i])) {
                  return sizes[i];
              }
          }
!         CustomMediaTray sampleTray = new CustomMediaTray("sample", "");
          Media[] trays = sampleTray.getSuperEnumTable();
          for (int i=0; i<trays.length; i++) {
              if (mediaName.equals(""+trays[i])) {
                  return trays[i];
              }
--- 1011,19 ---
  
      /**
       * Returns the matching standard Media using string comparison of names.
       */
      private Media getIPPMedia(String mediaName) {
!         CustomMediaSizeName sampleSize =
!                 CustomMediaSizeName.create("sample", "", 0, 0);
          Media[] sizes = sampleSize.getSuperEnumTable();
          for (int i=0; i<sizes.length; i++) {
              if (mediaName.equals(""+sizes[i])) {
                  return sizes[i];
              }
          }
!         CustomMediaTray sampleTray = CustomMediaTray.create("sample", "");
          Media[] trays = sampleTray.getSuperEnumTable();
          for (int i=0; i<trays.length; i++) {
              if (mediaName.equals(""+trays[i])) {
                  return trays[i];
              }

*** 1223,13 ***
          }
      }
  
  
      public synchronized PrintServiceAttributeSet getAttributes() {
!         // update getAttMap by sending again get-attributes IPP request
!         init = false;
!         initAttributes();
  
          HashPrintServiceAttributeSet attrs =
              new HashPrintServiceAttributeSet();
  
          for (int i=0; i < serviceAttributes.length; i++) {
--- 1225,21 ---
          }
      }
  
  
      public synchronized PrintServiceAttributeSet getAttributes() {
!         if (!init) {
!             // get all attributes for the first time.
!             initAttributes();
+         } else {
+             // only need service attributes updated.
+             // update getAttMap by sending again get-attributes IPP request
+             if ((urlConnection = getIPPConnection(myURL)) != null) {
+                 opGetAttributes();
+                 urlConnection.disconnect();
+             }
+         }
  
          HashPrintServiceAttributeSet attrs =
              new HashPrintServiceAttributeSet();
  
          for (int i=0; i < serviceAttributes.length; i++) {
< prev index next >