| 2542 | */ |
| 2543 | |
| 2544 | static void * /* O - Thread exit code */ |
| 2545 | monitor_printer( |
| 2546 | _cups_monitor_t *monitor) /* I - Monitoring data */ |
| 2547 | { |
| 2548 | http_t *http; /* Connection to printer */ |
| 2549 | ipp_t *request, /* IPP request */ |
| 2550 | *response; /* IPP response */ |
| 2551 | ipp_attribute_t *attr; /* Attribute in response */ |
| 2552 | int delay, /* Current delay */ |
| 2553 | prev_delay; /* Previous delay */ |
| 2554 | ipp_op_t job_op; /* Operation to use */ |
| 2555 | int job_id; /* Job ID */ |
| 2556 | const char *job_name; /* Job name */ |
| 2557 | ipp_jstate_t job_state; /* Job state */ |
| 2558 | const char *job_user; /* Job originating user name */ |
| 2559 | int password_tries = 0; /* Password tries */ |
| 2560 | |
| 2561 | |
| 2562 | /* |
| 2563 | * Make a copy of the printer connection... |
| 2564 | */ |
| 2565 | |
| 2566 | http = httpConnect2(monitor->hostname, monitor->port, NULL, AF_UNSPEC, |
| 2567 | monitor->encryption, 1, 0, NULL); |
| 2568 | httpSetTimeout(http, 30.0, timeout_cb, NULL); |
| 2569 | if (device_username[0]) |
| 2570 | cupsSetUser(device_username); |
| 2571 | |
| 2572 | cupsSetPasswordCB2((cups_password_cb2_t)password_cb, &password_tries); |
| 2573 | |
| 2574 | /* |
| 2575 | * Loop until the job is canceled, aborted, or completed. |
| 2576 | */ |
| 2577 | |
| 2578 | delay = _cupsNextDelay(0, &prev_delay); |
| 2579 | |
| 2580 | monitor->job_reasons = 0; |
| 2581 | |
| 2582 | while (monitor->job_state < IPP_JSTATE_CANCELED && !job_canceled) |
| 2583 | { |
| 2584 | /* |
| 2585 | * Reconnect to the printer as needed... |
| 2586 | */ |
| 2587 | |
| 2588 | if (httpGetFd(http) < 0) |
| 2589 | httpReconnect2(http, 30000, NULL); |
| 2590 | |
| 2591 | if (httpGetFd(http) >= 0) |
| 2592 | { |
| 2593 | /* |
| 2594 | * Connected, so check on the printer state... |
| 2595 | */ |
| 2596 | |
| 2597 | monitor->printer_state = check_printer_state(http, monitor->uri, |
| 2598 | monitor->resource, |
| 2599 | monitor->user, |
| 2600 | monitor->version); |
| 2601 | if (cupsLastError() <= IPP_STATUS_OK_CONFLICTING) |
nothing calls this directly
no test coverage detected