Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipp_attribute_t *attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER) is null #6194

Open
shinxxxxwon opened this issue Apr 23, 2024 · 0 comments

Comments

@shinxxxxwon
Copy link

We are implementing a function to print PDF by linking CUPS source using JNI in Android.

Tests were conducted on two printers.

  • Samsung SL-C1404W // Printed normally
  • Epson L6290 // 0x400(client-bad-request)
job_id = getJobId(monitor->http, monitor->http_resource,
                                          monitor->printer_uri, &new_state,
                                          monitor->requesting_user);
LOGE("1.job_id = %d", job_id); ///1.job_id = -1

The reason getJobId() returns -1 is because job_id was not found in ippFindAttribute().

int getJobId(http_t *http,
              char *http_resource,
              char *printer_uri,        /* I - URI buffer */
              job_state_dyn_t *job_state_dyn,
              const char *requesting_user) {
    int job_id = -1;
    // Requested print job attributes
    static const char *jattrs[] = {"job-id"};
    ipp_t *request = NULL;  /* IPP request object */
    ipp_t *response = NULL; /* IPP response object */

    request = ippNewRequest(IPP_GET_JOBS);

    LOGE("getJobId: http_resource => %s", http_resource); //getJobId: http_resource => /ipp/print
    LOGE("getJobId: printer_uri => %s", printer_uri);  //getJobId: printer_uri => ipp:https://printer_id_addr/ipp/print
    LOGE("getJobId: requesting_user => %s", requesting_user);

    if (request != NULL) { //request not null
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);
        ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1);
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
                     NULL, requesting_user);
        ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
                      sizeof(jattrs) / sizeof(jattrs[0]), NULL, jattrs);

        if ((response = ipp_doCupsRequest(http, request, http_resource, printer_uri)) == NULL) {
            job_state_dyn->job_state = IPP_JOB_STATE_UNABLE_TO_CONNECT;
            job_state_dyn->job_state_reasons[0] = IPP_JOB_STATE_REASON_UNABLE_TO_CONNECT;
        } else {

            ipp_attribute_t *attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER); //attr = NULL (not find "job_id" attr)
            if (attr != NULL) { 
                LOGE("getJobId() attr->integer : %d", attr->values[0].integer);
                job_id = ippGetInteger(attr, 0); 
                LOGE("getJobId(): attr != NULL -> %d", job_id);
            }
            else LOGE("getJobId() attr is NULL");
            LOGE("getJobId() job_id is %d", job_id);
        }
    }

    if (request != NULL) ippDelete(request);
    if (response != NULL) ippDelete(response);

    ///LOG
    LOGE("getJobId() returning job-id: %d", job_id); ///getJobId() returning job-id :-1
    return job_id;
}

Why can't I find the job_id attribute for a specific print?

Additionally, ported to use boringssl for printers that require tls upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant