Fix PrintServiceLookup.lookupPrintServices
Andrew Haley
aph@redhat.com
Tue Apr 27 16:20:00 GMT 2010
PrintServiceLookup.lookupPrintServices doesn't work because of
a few holes in its implementation. Fixed thusly.
Andrew.
2010-04-27 Andrew Haley <aph@redhat.com>
* gnu/javax/print/ipp/IppResponse.java (parseAttributes): Handle
IppValueTag.UNKNOWN.
* gnu/javax/print/ipp/IppRequest.java (writeOperationAttributes):
Handle RequestedAttributes.
* gnu/javax/print/ipp/IppPrintService.java (processResponse): Add
DocFlavor.SERVICE_FORMATTED.PAGEABLE and
DocFlavor.SERVICE_FORMATTED.PRINTABLE.
Index: gnu/javax/print/ipp/IppRequest.java
===================================================================
--- gnu/javax/print/ipp/IppRequest.java (revision 158610)
+++ gnu/javax/print/ipp/IppRequest.java (working copy)
@@ -434,6 +434,8 @@
PrinterURI printerUri = (PrinterURI) attributes.get(PrinterURI.class);
JobUri jobUri = (JobUri) attributes.get(JobUri.class);
JobId jobId = (JobId) attributes.get(JobId.class);
+ RequestedAttributes reqAttrs
+ = (RequestedAttributes)attributes.get(RequestedAttributes.class);
if (printerUri != null && jobId == null && jobUri == null)
{
write(printerUri);
@@ -467,6 +469,12 @@
logger.log(Component.IPP, "Attribute: Name: <" + jobUri.getCategory()
.getName() + "> Value: <" + jobUri.toString() + ">");
}
+ else if (reqAttrs != null)
+ {
+ write(reqAttrs);
+ attributes.remove(RequestedAttributes.class);
+ logger.log(Component.IPP, "RequestedAttributes: <" + reqAttrs + ">");
+ }
else
{
throw new IppException("Unknown target operation attribute combination.");
Index: gnu/javax/print/ipp/IppPrintService.java
===================================================================
--- gnu/javax/print/ipp/IppPrintService.java (revision 158610)
+++ gnu/javax/print/ipp/IppPrintService.java (working copy)
@@ -356,8 +356,17 @@
// should not happen, all fields are public
}
}
+
+ if (this.getClass()
+ .isAssignableFrom(gnu.javax.print.CupsPrintService.class))
+ {
+// CUPS always provides filters to convert from Postscript.
+// This logic looks odd, but it's what OpenJDK does.
+ flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
+ flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
+ }
}
-
+
// printer uris
Set uris = getPrinterAttributeSet(PrinterUriSupported.class);
printerUris = new ArrayList(uris.size());
Index: gnu/javax/print/ipp/IppResponse.java
===================================================================
--- gnu/javax/print/ipp/IppResponse.java (revision 158610)
+++ gnu/javax/print/ipp/IppResponse.java (working copy)
@@ -302,11 +302,14 @@
// out-of-band values
case IppValueTag.UNSUPPORTED:
case IppValueTag.UNKNOWN:
+ // TODO implement out-of-band handling
+ // We currently throw an exception to see when it occurs - not yet :-)
+ throw new IppException(
+ "Unexpected name value for out-of-band value tag " + tag);
case IppValueTag.NO_VALUE:
- // TODO implement out-of-band handling
- // We currently throw an exception to see when it occurs - not yet :-)
- throw new IppException(
- "Unexpected name value for out-of-band value tag");
+ attribute = null;
+
+ break;
case IppValueTag.INTEGER:
int intValue = IppUtilities.convertToInt(value);
attribute = IppUtilities.getIntegerAttribute(name, intValue);
More information about the Java-patches
mailing list