summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2018-11-19 21:52:11 +0100
committerDidier Raboud <odyx@debian.org>2018-11-19 21:52:11 +0100
commit4bffceb42f2a9bc3b38a38258b3a8e0f98918ce4 (patch)
tree6f4cf5fe01bf78fc055cb8459b08a78d313e0ad6
parent8d088ceb015d4dbf74232dcd47a9d15b4af8024b (diff)
Revert "Use Enable-Printer and Resume-Printer operations so we don't create a bogus printer (Issue #5305)"
This reverts commit 2b4e4ed7d80b47f9aaf6b98aaa85cf2c0e9273a9.
-rw-r--r--systemv/lpadmin.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c
index 8ea9f3f7b..5b78eb57b 100644
--- a/systemv/lpadmin.c
+++ b/systemv/lpadmin.c
@@ -1127,33 +1127,33 @@ enable_printer(http_t *http, /* I - Server connection */
DEBUG_printf(("enable_printer(%p, \"%s\")\n", http, printer));
/*
- * Send IPP_OP_ENABLE_PRINTER and IPP_OP_RESUME_PRINTER requests, which
+ * Build a IPP_OP_CUPS_ADD_MODIFY_PRINTER or IPP_OP_CUPS_ADD_MODIFY_CLASS request, which
* require the following attributes:
*
* attributes-charset
* attributes-natural-language
* printer-uri
* requesting-user-name
+ * printer-state
+ * printer-is-accepting-jobs
*/
- request = ippNewRequest(IPP_OP_ENABLE_PRINTER);
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
-
- ippDelete(cupsDoRequest(http, request, "/admin/"));
-
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
- {
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
-
- return (1);
- }
+ if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
+ request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
+ else
+ request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
- request = ippNewRequest(IPP_OP_RESUME_PRINTER);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+ "printer-uri", NULL, uri);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+ "requesting-user-name", NULL, cupsUser());
+ ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
+ IPP_PSTATE_IDLE);
+ ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ /*
+ * Do the request and get back a response...
+ */
ippDelete(cupsDoRequest(http, request, "/admin/"));
@@ -1163,8 +1163,8 @@ enable_printer(http_t *http, /* I - Server connection */
return (1);
}
-
- return (0);
+ else
+ return (0);
}