Package org.apache.harmony.x.print.ipp

Examples of org.apache.harmony.x.print.ipp.IppResponse


        String[] ippp = CUPSPrintServiceProvider.getIppPrintersByProperty();
        for (int j = 0; j < ippp.length; j++) {
            try {
                URI ippuri = new URI(ippp[j]);
                IppPrinter printer = new IppPrinter(ippuri);
                IppResponse response;

                response = printer.requestPrinterAttributes(
                        "printer-uri-supported", null);

                Vector gg = response
                        .getGroupVector(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
                if (gg != null) {
                    for (int i = 0, ii = gg.size(); i < ii; i++) {
                        IppAttributeGroup g = (IppAttributeGroup) gg.get(i);
                        int ai = g.findAttribute("printer-uri-supported");
View Full Code Here


        ArrayList ippservices = new ArrayList();

        URI cupsuri = null;
        IppClient c = null;
        IppRequest request;
        IppResponse response;
        IppAttributeGroup agroup;
        Vector va = new Vector();

        request = new IppRequest(1, 1, IppOperation.TAG_CUPS_GET_PRINTERS,
                "utf-8", "en-us");
        agroup = request.getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
        va.add("printer-uri-supported".getBytes());
        agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                "requested-attributes", va));

        try {
            cupsuri = new URI(cups);
            c = new IppClient(cupsuri);

            response = c.request(request.getBytes());

            Vector gg = response
                    .getGroupVector(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            if (gg != null) {
                for (int i = 0, ii = gg.size(); i < ii; i++) {
                    IppAttributeGroup g = (IppAttributeGroup) gg.get(i);
                    int ai = g.findAttribute("printer-uri-supported");
View Full Code Here

        for (int i = 0; i < cupses.length; i++) {
            try {
                URI cupsuri = new URI(cupses[i]);
                IppClient c = new IppClient(cupsuri);
                IppRequest request;
                IppResponse response;
                IppAttributeGroup agroup;
                Vector va = new Vector();

                request = new IppRequest(1, 1,
                        IppOperation.TAG_CUPS_GET_DEFAULT, "utf-8", "en-us");
                agroup = request
                        .getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
                va.add("printer-uri-supported".getBytes());
                agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                        "requested-attributes", va));

                response = c.request(request.getBytes());

                IppAttributeGroup g = response
                        .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
                if (g != null) {
                    int ai = g.findAttribute("printer-uri-supported");

                    if (ai >= 0) {
                        IppAttribute a = (IppAttribute) g.get(ai);
                        Vector v = a.getValue();
                        if (v.size() > 0) {
                            serviceName = new String((byte[]) v.get(0));
                            break;
                        }
                    }
                }
            } catch (URISyntaxException e) {
                //e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                //e.printStackTrace();
            }
        }
        if (serviceName != null && !serviceName.equals("")) {
            return serviceName;
        }

        String[] ippp = CUPSPrintServiceProvider.getIppPrintersByProperty();
        for (int i = 0; i < ippp.length; i++) {
            try {
                URI ippuri = new URI(ippp[i]);
                IppClient c = new IppClient(ippuri);
                IppRequest request;
                IppResponse response;
                IppAttributeGroup agroup;
                Vector va = new Vector();

                request = new IppRequest(1, 1,
                        IppOperation.GET_PRINTER_ATTRIBUTES, "utf-8", "en-us");
                agroup = request
                        .getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
                va.add("printer-uri-supported".getBytes());
                agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                        "requested-attributes", va));

                response = c.request(request.getBytes());

                IppAttributeGroup g = response
                        .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
                if (g != null) {
                    int ai = g.findAttribute("printer-uri-supported");

                    if (ai >= 0) {
View Full Code Here

     * @see org.apache.harmony.x.print.PrintClient#getAttributes()
     */
    public PrintServiceAttributeSet getAttributes() {
        synchronized (this) {
            try {
                IppResponse response;
                IppAttributeGroup agroup;
                IppAttribute attr;
                Object[] attrx = new Object[0];

                response = printer.requestPrinterDescriptionAttributes();
                agroup = response
                        .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
                if (agroup != null) {
                    attributeset.clear();
                    for (int i = 0, ii = agroup.size(); i < ii; i++) {
                        attr = (IppAttribute) agroup.get(i);
View Full Code Here

     */
    public Class[] getSupportedAttributeCategories() {
        ArrayList clazz = new ArrayList();

        try {
            IppResponse response = printer.requestPrinterAttributes();
            IppAttributeGroup agroup = response
                    .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            String aname;
            Class claz;
            IppAttribute attr;

View Full Code Here

        if (Media.class.isAssignableFrom(category)) {
            category = Media.class;
        }
        try {
            IppResponse response = printer.requestPrinterAttributes();
            IppAttributeGroup agroup = response
                    .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            IppAttribute attr;
            String aname;
            int andex;
View Full Code Here

        }

        boolean supported = false;
        try {
            IppDocument document;
            IppResponse response;
            IppAttributeGroup agroup;
            IppAttributeGroupSet agroupset;
            Attribute[] attrs;
            String mime = null;
            String aname;

            aname = Ipp2Java.getIppAttributeNameByClass(attribute.getClass(),
                    -1);
            if (aname == null) {
                return false;
            }
            if (flavor == null) {
                mime = "application/octet-stream";
            } else {
                mime = java2ipp(flavor).getMimeType();
            }
            if (attributes == null || attributes.isEmpty()) {
                document = new IppDocument("Qwerty", mime, "");
                agroupset = new IppAttributeGroupSet();
                agroupset.setAttribute(aname, Ipp2Java.getIppByJava(attribute));
                response = printer.requestValidateJob(aname, document,
                        agroupset);
                agroup = response
                        .getGroup(IppAttributeGroup.TAG_UNSUPPORTED_ATTRIBUTES);

                if (agroup == null) {
                    supported = true;
                } else if (agroup != null && agroup.findAttribute(aname) < 0) {
                    supported = true;
                }
            } else {
                document = new IppDocument("Qwerty", mime, "");
                agroupset = new IppAttributeGroupSet();
                agroupset.setAttribute(aname, Ipp2Java.getIppByJava(attribute));
                attrs = attributes.toArray();
                for (int i = 0, ii = attrs.length; i < ii; i++) {
                    agroupset.setAttribute(Ipp2Java.getIppAttributeNameByClass(
                            attrs[i].getClass(), -1), Ipp2Java
                            .getIppByJava(attrs[i]));
                }

                response = printer.requestValidateJob(aname, document,
                        agroupset);
                agroup = response
                        .getGroup(IppAttributeGroup.TAG_UNSUPPORTED_ATTRIBUTES);

                if (agroup == null) {
                    supported = true;
                } else if (agroup != null && agroup.findAttribute(aname) < 0) {
View Full Code Here

            String aname = Ipp2Java.getIppAttributeNameByClass(category, 0)
                    + "-supported";
            doVerbose(2,
                    "CUPSClient.java: getSupportedAttributeValues(): ipp attribute: "
                            + aname);
            IppResponse response = printer.requestPrinterAttributes(aname,
                    (flavor == null ? null : java2ipp(flavor).getMimeType()));
            doVerbose(2,
                    "CUPSClient.java: getSupportedAttributeValues(): response: "
                            + response.toString());
            IppAttributeGroup agroup = response
                    .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            doVerbose(1,
                    "CUPSClient.java: getSupportedAttributeValues(): agroup: "
                            + agroup.toString());
            if (agroup != null) {
View Full Code Here

     * request IppPrinter printer to print document
     */
    private void printsimple(Doc doc, HashAttributeSet as)
            throws PrintException {
        IppDocument document;
        IppResponse response;
        IppAttributeGroupSet agroupset;
        Attribute[] attrs;
        DocFlavor df = doc.getDocFlavor();
        String docname = doc.toString();

        try {
            document = new IppDocument(docname, java2ipp(df).getMimeType(), doc
                    .getPrintData());

            agroupset = new IppAttributeGroupSet();
            attrs = as.toArray();
            for (int i = 0, ii = attrs.length; i < ii; i++) {
                agroupset.setAttribute(Ipp2Java.getIppAttributeNameByClass(
                        attrs[i].getClass(), -1), Ipp2Java
                        .getIppByJava(attrs[i]));
            }
            document.setAgroups(agroupset);

            doVerbose(1, "Validating print job...");
            response = printer.requestValidateJob(docname, document, agroupset);
            doVerbose(1, response.toString());
            checkResponseIsZero(response, "IPP Validate Job: \n");
            doVerbose(1, "Validate OK");

            doVerbose(1, "Printing " + docname + "...");
            response = printer.requestPrintJob(docname, document, agroupset);
            doVerbose(1, response.toString());
            checkResponseIsZero(response, "IPP Print Job: \n");
            doVerbose(1, "Printing OK");
        } catch (PrintException e) {
            throw e;
        } catch (Exception e) {
View Full Code Here

         */
        if (mime.equals("application/postscript")) {
            try {
                IppDocument document = new IppDocument("Qwerty",
                        "application/postscript", "");
                IppResponse response = printer.requestValidateJob("Qwerty",
                        document, null);
                if (response.getStatusCode() != 0) {
                    document = new IppDocument("Qwerty", "application/ps", "");
                    response = printer.requestValidateJob("Qwerty", document,
                            null);
                    if (response.getStatusCode() == 0) {
                        if (pDocFlavor instanceof DocFlavor.INPUT_STREAM) {
                            ippDocFlavor = new DocFlavor.INPUT_STREAM(
                                    "application/ps");
                        } else if (ippDocFlavor instanceof DocFlavor.BYTE_ARRAY) {
                            ippDocFlavor = new DocFlavor.BYTE_ARRAY(
View Full Code Here

TOP

Related Classes of org.apache.harmony.x.print.ipp.IppResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.