| 1771 | */ |
| 1772 | |
| 1773 | static void |
| 1774 | do_delete_class(http_t *http) /* I - HTTP connection */ |
| 1775 | { |
| 1776 | ipp_t *request; /* IPP request */ |
| 1777 | char uri[HTTP_MAX_URI]; /* Job URI */ |
| 1778 | const char *pclass; /* Printer class name */ |
| 1779 | |
| 1780 | |
| 1781 | /* |
| 1782 | * Get form variables... |
| 1783 | */ |
| 1784 | |
| 1785 | if (cgiGetVariable("CONFIRM") == NULL) |
| 1786 | { |
| 1787 | cgiStartHTML(cgiText(_("Delete Class"))); |
| 1788 | cgiCopyTemplateLang("class-confirm.tmpl"); |
| 1789 | cgiEndHTML(); |
| 1790 | return; |
| 1791 | } |
| 1792 | |
| 1793 | if ((pclass = cgiGetTextfield("PRINTER_NAME")) != NULL) |
| 1794 | httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, |
| 1795 | "localhost", 0, "/classes/%s", pclass); |
| 1796 | else |
| 1797 | { |
| 1798 | cgiStartHTML(cgiText(_("Delete Class"))); |
| 1799 | cgiSetVariable("ERROR", cgiText(_("Missing form variable"))); |
| 1800 | cgiCopyTemplateLang("error.tmpl"); |
| 1801 | cgiEndHTML(); |
| 1802 | return; |
| 1803 | } |
| 1804 | |
| 1805 | /* |
| 1806 | * Build a CUPS_DELETE_CLASS request, which requires the following |
| 1807 | * attributes: |
| 1808 | * |
| 1809 | * attributes-charset |
| 1810 | * attributes-natural-language |
| 1811 | * printer-uri |
| 1812 | */ |
| 1813 | |
| 1814 | request = ippNewRequest(CUPS_DELETE_CLASS); |
| 1815 | |
| 1816 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", |
| 1817 | NULL, uri); |
| 1818 | |
| 1819 | /* |
| 1820 | * Do the request and get back a response... |
| 1821 | */ |
| 1822 | |
| 1823 | ippDelete(cupsDoRequest(http, request, "/admin/")); |
| 1824 | |
| 1825 | /* |
| 1826 | * Show the results... |
| 1827 | */ |
| 1828 | |
| 1829 | if (cupsLastError() == IPP_NOT_AUTHORIZED) |
| 1830 | { |
no test coverage detected