| 2435 | */ |
| 2436 | |
| 2437 | static ipp_pstate_t /* O - Current printer-state */ |
| 2438 | check_printer_state( |
| 2439 | http_t *http, /* I - HTTP connection */ |
| 2440 | const char *uri, /* I - Printer URI */ |
| 2441 | const char *resource, /* I - Resource path */ |
| 2442 | const char *user, /* I - Username, if any */ |
| 2443 | int version) /* I - IPP version */ |
| 2444 | { |
| 2445 | ipp_t *request, /* IPP request */ |
| 2446 | *response; /* IPP response */ |
| 2447 | ipp_attribute_t *attr; /* Attribute in response */ |
| 2448 | ipp_pstate_t printer_state = IPP_PSTATE_STOPPED; |
| 2449 | /* Current printer-state */ |
| 2450 | |
| 2451 | |
| 2452 | /* |
| 2453 | * Send a Get-Printer-Attributes request and log the results... |
| 2454 | */ |
| 2455 | |
| 2456 | request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); |
| 2457 | ippSetVersion(request, version / 10, version % 10); |
| 2458 | |
| 2459 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", |
| 2460 | NULL, uri); |
| 2461 | |
| 2462 | if (user && user[0]) |
| 2463 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, |
| 2464 | "requesting-user-name", NULL, user); |
| 2465 | |
| 2466 | ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, |
| 2467 | "requested-attributes", |
| 2468 | (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs); |
| 2469 | |
| 2470 | fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10, ippOpString(ippGetOperation(request)), ippGetRequestId(request)); |
| 2471 | debug_attributes(request); |
| 2472 | |
| 2473 | if ((response = cupsDoRequest(http, request, resource)) != NULL) |
| 2474 | { |
| 2475 | report_printer_state(response); |
| 2476 | |
| 2477 | if ((attr = ippFindAttribute(response, "printer-state", |
| 2478 | IPP_TAG_ENUM)) != NULL) |
| 2479 | printer_state = (ipp_pstate_t)attr->values[0].integer; |
| 2480 | } |
| 2481 | |
| 2482 | fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n", |
| 2483 | ippErrorString(cupsLastError()), cupsLastErrorString()); |
| 2484 | debug_attributes(response); |
| 2485 | ippDelete(response); |
| 2486 | |
| 2487 | /* |
| 2488 | * Return the printer-state value... |
| 2489 | */ |
| 2490 | |
| 2491 | return (printer_state); |
| 2492 | } |
| 2493 | |
| 2494 |
no test coverage detected