| 1856 | */ |
| 1857 | |
| 1858 | static void |
| 1859 | do_delete_printer(http_t *http) /* I - HTTP connection */ |
| 1860 | { |
| 1861 | ipp_t *request; /* IPP request */ |
| 1862 | char uri[HTTP_MAX_URI]; /* Job URI */ |
| 1863 | const char *printer; /* Printer printer name */ |
| 1864 | |
| 1865 | |
| 1866 | /* |
| 1867 | * Get form variables... |
| 1868 | */ |
| 1869 | |
| 1870 | if (cgiGetVariable("CONFIRM") == NULL) |
| 1871 | { |
| 1872 | cgiStartHTML(cgiText(_("Delete Printer"))); |
| 1873 | cgiCopyTemplateLang("printer-confirm.tmpl"); |
| 1874 | cgiEndHTML(); |
| 1875 | return; |
| 1876 | } |
| 1877 | |
| 1878 | if ((printer = cgiGetTextfield("PRINTER_NAME")) != NULL) |
| 1879 | httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, |
| 1880 | "localhost", 0, "/printers/%s", printer); |
| 1881 | else |
| 1882 | { |
| 1883 | cgiStartHTML(cgiText(_("Delete Printer"))); |
| 1884 | cgiSetVariable("ERROR", cgiText(_("Missing form variable"))); |
| 1885 | cgiCopyTemplateLang("error.tmpl"); |
| 1886 | cgiEndHTML(); |
| 1887 | return; |
| 1888 | } |
| 1889 | |
| 1890 | /* |
| 1891 | * Build a CUPS_DELETE_PRINTER request, which requires the following |
| 1892 | * attributes: |
| 1893 | * |
| 1894 | * attributes-charset |
| 1895 | * attributes-natural-language |
| 1896 | * printer-uri |
| 1897 | */ |
| 1898 | |
| 1899 | request = ippNewRequest(CUPS_DELETE_PRINTER); |
| 1900 | |
| 1901 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", |
| 1902 | NULL, uri); |
| 1903 | |
| 1904 | /* |
| 1905 | * Do the request and get back a response... |
| 1906 | */ |
| 1907 | |
| 1908 | ippDelete(cupsDoRequest(http, request, "/admin/")); |
| 1909 | |
| 1910 | /* |
| 1911 | * Show the results... |
| 1912 | */ |
| 1913 | |
| 1914 | if (cupsLastError() == IPP_NOT_AUTHORIZED) |
| 1915 | { |
no test coverage detected