| 304 | */ |
| 305 | |
| 306 | static void |
| 307 | do_am_class(http_t *http, /* I - HTTP connection */ |
| 308 | int modify) /* I - Modify the printer? */ |
| 309 | { |
| 310 | int i, j; /* Looping vars */ |
| 311 | int element; /* Element number */ |
| 312 | int num_printers; /* Number of printers */ |
| 313 | ipp_t *request, /* IPP request */ |
| 314 | *response; /* IPP response */ |
| 315 | ipp_attribute_t *attr; /* member-uris attribute */ |
| 316 | char uri[HTTP_MAX_URI]; /* Device or printer URI */ |
| 317 | const char *name, /* Pointer to class name */ |
| 318 | *op, /* Operation name */ |
| 319 | *ptr; /* Pointer to CGI variable */ |
| 320 | const char *title; /* Title of page */ |
| 321 | static const char * const pattrs[] = /* Requested printer attributes */ |
| 322 | { |
| 323 | "member-names", |
| 324 | "printer-info", |
| 325 | "printer-location" |
| 326 | }; |
| 327 | |
| 328 | |
| 329 | title = cgiText(modify ? _("Modify Class") : _("Add Class")); |
| 330 | op = cgiGetVariable("OP"); |
| 331 | name = cgiGetTextfield("PRINTER_NAME"); |
| 332 | |
| 333 | if (cgiGetTextfield("PRINTER_LOCATION") == NULL) |
| 334 | { |
| 335 | /* |
| 336 | * Build a CUPS_GET_PRINTERS request, which requires the |
| 337 | * following attributes: |
| 338 | * |
| 339 | * attributes-charset |
| 340 | * attributes-natural-language |
| 341 | */ |
| 342 | |
| 343 | request = ippNewRequest(CUPS_GET_PRINTERS); |
| 344 | |
| 345 | ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type", |
| 346 | CUPS_PRINTER_LOCAL); |
| 347 | ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type-mask", |
| 348 | CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE); |
| 349 | |
| 350 | /* |
| 351 | * Do the request and get back a response... |
| 352 | */ |
| 353 | |
| 354 | cgiClearVariables(); |
| 355 | if (op) |
| 356 | cgiSetVariable("OP", op); |
| 357 | if (name) |
| 358 | cgiSetVariable("PRINTER_NAME", name); |
| 359 | |
| 360 | if ((response = cupsDoRequest(http, request, "/")) != NULL) |
| 361 | { |
| 362 | /* |
| 363 | * Create MEMBER_URIS and MEMBER_NAMES arrays... |
no test coverage detected