MCPcopy Create free account
hub / github.com/OpenPrinting/cups / show_class

Function show_class

cgi-bin/classes.c:439–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437 */
438
439static void
440show_class(http_t *http, /* I - Connection to server */
441 const char *pclass) /* I - Name of class */
442{
443 ipp_t *request, /* IPP request */
444 *response; /* IPP response */
445 ipp_attribute_t *attr; /* IPP attribute */
446 char uri[HTTP_MAX_URI]; /* Printer URI */
447 char refresh[1024]; /* Refresh URL */
448
449
450 /*
451 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
452 * attributes:
453 *
454 * attributes-charset
455 * attributes-natural-language
456 * printer-uri
457 */
458
459 request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
460
461 httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
462 "localhost", 0, "/classes/%s", pclass);
463 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
464 uri);
465
466 cgiGetAttributes(request, "class.tmpl");
467
468 /*
469 * Do the request and get back a response...
470 */
471
472 if ((response = cupsDoRequest(http, request, "/")) != NULL)
473 {
474 /*
475 * Got the result; set the CGI variables and check the status of a
476 * single-queue request...
477 */
478
479 cgiSetIPPVars(response, NULL, NULL, NULL, 0);
480
481 if (pclass && (attr = ippFindAttribute(response, "printer-state",
482 IPP_TAG_ENUM)) != NULL &&
483 attr->values[0].integer == IPP_PRINTER_PROCESSING)
484 {
485 /*
486 * Class is processing - automatically refresh the page until we
487 * are done printing...
488 */
489
490 cgiFormEncode(uri, pclass, sizeof(uri));
491 snprintf(refresh, sizeof(refresh), "10;URL=/classes/%s", uri);
492 cgiSetVariable("refresh_page", refresh);
493 }
494
495 /*
496 * Delete the response...

Callers 1

mainFunction · 0.85

Calls 15

ippNewRequestFunction · 0.85
httpAssembleURIfFunction · 0.85
ippAddStringFunction · 0.85
cgiGetAttributesFunction · 0.85
cupsDoRequestFunction · 0.85
cgiSetIPPVarsFunction · 0.85
ippFindAttributeFunction · 0.85
cgiFormEncodeFunction · 0.85
cgiSetVariableFunction · 0.85
ippDeleteFunction · 0.85
cgiStartHTMLFunction · 0.85
cgiCopyTemplateLangFunction · 0.85

Tested by

no test coverage detected