diff --git a/pappl/printer-private.h b/pappl/printer-private.h
index a58226f5..79bd5c74 100644
--- a/pappl/printer-private.h
+++ b/pappl/printer-private.h
@@ -133,18 +133,14 @@ extern bool _papplPrinterSetAttributes(pappl_client_t *client, pappl_printer_t
extern void _papplPrinterUnregisterDNSSDNoLock(pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebCancelAllJobs(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
-extern void _papplPrinterWebCancelJob(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebConfig(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebConfigFinalize(pappl_printer_t *printer, cups_len_t num_form, cups_option_t *form) _PAPPL_PRIVATE;
extern void _papplPrinterWebDefaults(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebDelete(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
-extern void _papplPrinterWebHoldJob(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebHome(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebIteratorCallback(pappl_printer_t *printer, pappl_client_t *client) _PAPPL_PRIVATE;
extern void _papplPrinterWebJobs(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebMedia(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
-extern void _papplPrinterWebReprintJob(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
-extern void _papplPrinterWebReleaseJob(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern void _papplPrinterWebSupplies(pappl_client_t *client, pappl_printer_t *printer) _PAPPL_PRIVATE;
extern const char *_papplColorModeString(pappl_color_mode_t value) _PAPPL_PRIVATE;
diff --git a/pappl/printer-webif.c b/pappl/printer-webif.c
index d206c8f1..90f6c8fe 100644
--- a/pappl/printer-webif.c
+++ b/pappl/printer-webif.c
@@ -99,105 +99,6 @@ _papplPrinterWebCancelAllJobs(
}
-//
-// '_papplPrinterWebCancelJob()' - Cancel a job.
-//
-
-void
-_papplPrinterWebCancelJob(
- pappl_client_t *client, // I - Client
- pappl_printer_t *printer) // I - Printer
-{
- int job_id = 0; // Job ID to cancel
- pappl_job_t *job; // Job to cancel
- const char *status = NULL; // Status message, if any
- cups_len_t num_form; // Number of form variables
- cups_option_t *form; // Form variables
- const char *value; // Value of form variable
-
-
- if (!papplClientHTMLAuthorize(client))
- return;
-
- if (client->operation == HTTP_STATE_GET)
- {
- if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
- {
- status = _PAPPL_LOC("Invalid GET data.");
- }
- else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
- {
- char *end; // End of value
-
- job_id = (int)strtol(value, &end, 10);
-
- if (errno == ERANGE || *end)
- {
- job_id = 0;
- status = _PAPPL_LOC("Invalid job ID.");
- }
- }
-
- cupsFreeOptions(num_form, form);
- }
- else if (client->operation == HTTP_STATE_POST)
- {
- if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
- {
- status = _PAPPL_LOC("Invalid form data.");
- }
- else if (!papplClientIsValidForm(client, (int)num_form, form))
- {
- status = _PAPPL_LOC("Invalid form submission.");
- }
- else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
- {
- // Get the job to cancel
- char *end; // End of value
-
- job_id = (int)strtol(value, &end, 10);
- if (errno == ERANGE || *end)
- {
- status = _PAPPL_LOC("Invalid job ID.");
- }
- else if ((job = papplPrinterFindJob(printer, job_id)) != NULL)
- {
- char path[1024]; // Resource path
-
- papplJobCancel(job);
- snprintf(path, sizeof(path), "%s/jobs", printer->uriname);
- papplClientRespondRedirect(client, HTTP_STATUS_FOUND, path);
- cupsFreeOptions(num_form, form);
- return;
- }
- else
- {
- status = _PAPPL_LOC("Invalid Job ID.");
- }
-
- cupsFreeOptions(num_form, form);
- }
- else
- {
- status = _PAPPL_LOC("Invalid form submission.");
- }
- }
-
- papplClientHTMLPrinterHeader(client, printer, _PAPPL_LOC("Cancel Job"), 0, NULL, NULL);
-
- if (status)
- papplClientHTMLPrintf(client, "
");
_papplClientHTMLPutLinks(client, printer->links, PAPPL_LOPTIONS_STATUS);
+ if (!printer->hold_new_jobs)
+ {
+ papplClientHTMLStartForm(client, uri, false);
+ papplClientHTMLPrintf(client, "
", papplClientGetLocString(client, _PAPPL_LOC("Hold New Jobs")));
+ }
+
if (printer->driver_data.identify_supported)
{
papplClientHTMLStartForm(client, uri, false);
@@ -1157,6 +978,12 @@ _papplPrinterWebIteratorCallback(
papplClientHTMLPrintf(client, "
", papplClientGetLocString(client, _PAPPL_LOC("Print Test Page")));
}
+ if (printer->hold_new_jobs)
+ {
+ papplClientHTMLStartForm(client, uri, false);
+ papplClientHTMLPrintf(client, "
", papplClientGetLocString(client, _PAPPL_LOC("Release Held New Jobs")));
+ }
+
if (printer->system->options & PAPPL_SOPTIONS_MULTI_QUEUE)
{
if (printer->state == IPP_PSTATE_STOPPED)
@@ -1196,12 +1023,14 @@ _papplPrinterWebJobs(
ipp_pstate_t printer_state; // Printer state
int job_index = 1, // Job index
limit = 20; // Jobs per page
-
+ const char *status = NULL; // Status message
+ bool refresh; // Refresh the window?
if (!papplClientHTMLAuthorize(client))
return;
printer_state = papplPrinterGetState(printer);
+ refresh = printer_state == IPP_PSTATE_PROCESSING;
if (client->operation == HTTP_STATE_GET)
{
@@ -1215,6 +1044,117 @@ _papplPrinterWebJobs(
cupsFreeOptions(num_form, form);
}
+ else if (client->operation == HTTP_STATE_POST)
+ {
+ cups_len_t num_form = 0; // Number of form variable
+ cups_option_t *form = NULL; // Form variables
+ const char *value; // Value of form variable
+ int job_id = 0; // Job ID to cancel
+ pappl_job_t *job; // Job to cancel
+ const char *action; // Form action
+
+ if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
+ {
+ status = _PAPPL_LOC("Invalid form data.");
+ }
+ else if (!papplClientIsValidForm(client, (int)num_form, form))
+ {
+ status = _PAPPL_LOC("Invalid form submission.");
+ }
+ else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
+ {
+ char *end; // End of value
+
+ job_id = (int)strtol(value, &end, 10);
+
+ if (errno == ERANGE || *end)
+ {
+ status = _PAPPL_LOC("Invalid job ID.");
+ }
+ else if ((job = papplPrinterFindJob(printer, job_id)) != NULL)
+ {
+ const char *username; // Username
+
+ if (client->username[0])
+ username = client->username;
+ else
+ username = "guest";
+
+ if ((action = cupsGetOption("action", num_form, form)) == NULL)
+ {
+ status = _PAPPL_LOC("Missing action.");
+ }
+ else if (!strcmp(action, "cancel-job"))
+ {
+ papplJobCancel(job);
+ status = _PAPPL_LOC("Job canceled.");
+ }
+ else if (!strcmp(action, "hold-job"))
+ {
+ papplJobHold(job, username, "indefinite", 0);
+ status = _PAPPL_LOC("Job held.");
+ }
+ else if (!strcmp(action, "release-job"))
+ {
+ papplJobRelease(job, username);
+ status = _PAPPL_LOC("Job released.");
+ refresh = true;
+ }
+ else if (!strcmp(action, "reprint-job"))
+ {
+ // Copy the job...
+ pappl_job_t *new_job; // New job
+
+ if ((new_job = _papplJobCreate(printer, 0, username, job->format, job->name, job->attrs)) != NULL)
+ {
+ // Copy the job file...
+ int oldfd, // Old job file
+ newfd; // New job file
+ char filename[1024], // Job filename
+ buffer[8192]; // Copy buffer
+ ssize_t bytes; // Bytes read...
+
+ if ((oldfd = open(job->filename, O_RDONLY | O_BINARY)) >= 0)
+ {
+ if ((newfd = papplJobOpenFile(new_job, filename, sizeof(filename), printer->system->directory, NULL, "w")) >= 0)
+ {
+ while ((bytes = read(oldfd, buffer, sizeof(buffer))) > 0)
+ write(newfd, buffer, (size_t)bytes);
+
+ close(oldfd);
+ close(newfd);
+
+ // Submit the job for processing...
+ _papplJobSubmitFile(new_job, filename);
+ status = _PAPPL_LOC("Reprinted job.");
+ refresh = true;
+ }
+
+ close(oldfd);
+ }
+ }
+
+ if (!status)
+ status = _PAPPL_LOC("Unable to copy print job.");
+ }
+ else
+ {
+ papplLogClient(client, PAPPL_LOGLEVEL_DEBUG, "action='%s'", action);
+ status = _PAPPL_LOC("Unknown action.");
+ }
+ }
+ else
+ {
+ status = _PAPPL_LOC("Invalid Job ID.");
+ }
+ }
+ else
+ {
+ status = _PAPPL_LOC("Missing job ID.");
+ }
+
+ cupsFreeOptions(num_form, form);
+ }
if (cupsArrayGetCount(printer->active_jobs) > 0)
{
@@ -1222,13 +1162,21 @@ _papplPrinterWebJobs(
httpAssembleURIf(HTTP_URI_CODING_ALL, url, sizeof(url), "https", NULL, client->host_field, client->host_port, "%s/cancelall", printer->uriname);
- papplClientHTMLPrinterHeader(client, printer, _PAPPL_LOC("Jobs"), printer_state == IPP_PSTATE_PROCESSING ? 10 : 0, _PAPPL_LOC("Cancel All Jobs"), url);
+ papplClientHTMLPrinterHeader(client, printer, _PAPPL_LOC("Jobs"), refresh ? 10 : 0, _PAPPL_LOC("Cancel All Jobs"), url);
}
else
{
papplClientHTMLPrinterHeader(client, printer, _PAPPL_LOC("Jobs"), printer_state == IPP_PSTATE_PROCESSING ? 10 : 0, NULL, NULL);
}
+ if (status)
+ papplClientHTMLPrintf(client,
+ "
\n", papplClientGetLocString(client, status));
+
if (papplPrinterGetNumberOfJobs(printer) > 0)
{
job_pager(client, printer, job_index, limit);
@@ -1421,239 +1369,6 @@ _papplPrinterWebMedia(
}
-//
-// '_papplPrinterWebReleaseJob()' - Resume a job.
-//
-
-void
-_papplPrinterWebReleaseJob(
- pappl_client_t *client, // I - Client
- pappl_printer_t *printer) // I - Printer
-{
- int job_id = 0; // Job ID to cancel
- pappl_job_t *job; // Job to cancel
- const char *status = NULL; // Status message, if any
- cups_len_t num_form; // Number of form variables
- cups_option_t *form; // Form variables
- const char *value; // Value of form variable
-
-
- if (!papplClientHTMLAuthorize(client))
- return;
-
- if (client->operation == HTTP_STATE_GET)
- {
- if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
- {
- status = _PAPPL_LOC("Invalid GET data.");
- }
- else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
- {
- char *end; // End of value
-
- job_id = (int)strtol(value, &end, 10);
-
- if (errno == ERANGE || *end)
- {
- job_id = 0;
- status = _PAPPL_LOC("Invalid job ID.");
- }
- }
-
- cupsFreeOptions(num_form, form);
- }
- else if (client->operation == HTTP_STATE_POST)
- {
- if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
- {
- status = _PAPPL_LOC("Invalid form data.");
- }
- else if (!papplClientIsValidForm(client, (int)num_form, form))
- {
- status = _PAPPL_LOC("Invalid form submission.");
- }
- else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
- {
- // Get the job to cancel
- char *end; // End of value
-
- job_id = (int)strtol(value, &end, 10);
- if (errno == ERANGE || *end)
- {
- status = _PAPPL_LOC("Invalid job ID.");
- }
- else if ((job = papplPrinterFindJob(printer, job_id)) != NULL)
- {
- char path[1024]; // Resource path
-
- papplJobRelease(job, client->username);
- snprintf(path, sizeof(path), "%s/jobs", printer->uriname);
- papplClientRespondRedirect(client, HTTP_STATUS_FOUND, path);
- cupsFreeOptions(num_form, form);
- return;
- }
- else
- {
- status = _PAPPL_LOC("Invalid Job ID.");
- }
-
- cupsFreeOptions(num_form, form);
- }
- else
- {
- status = _PAPPL_LOC("Invalid form submission.");
- }
- }
-
- papplClientHTMLPrinterHeader(client, printer, _PAPPL_LOC("Release Job"), 0, NULL, NULL);
-
- if (status)
- papplClientHTMLPrintf(client, "
%s
\n", papplClientGetLocString(client, status));
-
- if (job_id)
- {
- papplClientHTMLStartForm(client, client->uri, false);
- papplClientHTMLPrintf(client, "
\n", job_id, papplClientGetLocString(client, _PAPPL_LOC("Confirm Release Job")));
- }
-
- papplClientHTMLFooter(client);
-}
-
-
-//
-// '_papplPrinterWebReprintJob()' - Reprint a job.
-//
-
-void
-_papplPrinterWebReprintJob(
- pappl_client_t *client, // I - Client
- pappl_printer_t *printer) // I - Printer
-{
- int job_id = 0; // Job ID to reprint
- pappl_job_t *job, // Job to reprint
- *new_job; // New job
- const char *status = NULL; // Status message, if any
- cups_len_t num_form; // Number of form variables
- cups_option_t *form; // Form variables
- const char *value; // Value of form variable
-
-
- if (!papplClientHTMLAuthorize(client))
- return;
-
- if (client->operation == HTTP_STATE_GET)
- {
- if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
- {
- status = _PAPPL_LOC("Invalid GET data.");
- }
- else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
- {
- char *end; // End of value
-
- job_id = (int)strtol(value, &end, 10);
-
- if (errno == ERANGE || *end)
- {
- job_id = 0;
- status = _PAPPL_LOC("Invalid job ID.");
- }
- }
-
- cupsFreeOptions(num_form, form);
- }
- else if (client->operation == HTTP_STATE_POST)
- {
- if ((num_form = (cups_len_t)papplClientGetForm(client, &form)) == 0)
- {
- status = _PAPPL_LOC("Invalid form data.");
- }
- else if (!papplClientIsValidForm(client, (int)num_form, form))
- {
- status = _PAPPL_LOC("Invalid form submission.");
- }
- else if ((value = cupsGetOption("job-id", num_form, form)) != NULL)
- {
- // Get the job to cancel
- char *end; // End of value
-
- job_id = (int)strtol(value, &end, 10);
- if (errno == ERANGE || *end)
- {
- status = _PAPPL_LOC("Invalid job ID.");
- }
- else if ((job = papplPrinterFindJob(printer, job_id)) != NULL)
- {
- char path[1024]; // Resource path
- const char *username; // Username
-
- if (client->username[0])
- username = client->username;
- else
- username = "guest";
-
- // Copy the job...
- if ((new_job = _papplJobCreate(printer, 0, username, job->format, job->name, job->attrs)) != NULL)
- {
- // Copy the job file...
- int oldfd, // Old job file
- newfd; // New job file
- char buffer[8192]; // Copy buffer
- ssize_t bytes; // Bytes read...
-
- if ((oldfd = open(job->filename, O_RDONLY | O_BINARY)) >= 0)
- {
- if ((newfd = papplJobOpenFile(new_job, path, sizeof(path), printer->system->directory, NULL, "w")) >= 0)
- {
- while ((bytes = read(oldfd, buffer, sizeof(buffer))) > 0)
- write(newfd, buffer, (size_t)bytes);
-
- close(oldfd);
- close(newfd);
-
- // Submit the job for processing...
- _papplJobSubmitFile(new_job, path);
-
- snprintf(path, sizeof(path), "%s/jobs", printer->uriname);
- papplClientRespondRedirect(client, HTTP_STATUS_FOUND, path);
- cupsFreeOptions(num_form, form);
- return;
- }
-
- close(oldfd);
- }
- }
-
- status = _PAPPL_LOC("Unable to copy print job.");
- }
- else
- {
- status = _PAPPL_LOC("Invalid Job ID.");
- }
-
- cupsFreeOptions(num_form, form);
- }
- else
- {
- status = _PAPPL_LOC("Invalid form submission.");
- }
- }
-
- papplClientHTMLPrinterHeader(client, printer, _PAPPL_LOC("Reprint Job"), 0, NULL, NULL);
-
- if (status)
- papplClientHTMLPrintf(client, "
%s
\n", papplClientGetLocString(client, status));
-
- if (job_id)
- {
- papplClientHTMLStartForm(client, client->uri, false);
- papplClientHTMLPrintf(client, "
\n", job_id, papplClientGetLocString(client, _PAPPL_LOC("Confirm Reprint Job")));
- }
-
- papplClientHTMLFooter(client);
-}
-
-
//
// '_papplPrinterWebSupplies()' - Show the printer supplies web page.
//
@@ -1728,10 +1443,13 @@ job_cb(pappl_job_t *job, // I - Job
bool show_cancel = false, // Show the "cancel" button?
show_hold = false, // Show the "hold" button?
show_release = false; // Show the "release" button?
- char when[256], // When job queued/started/finished
+ char uri[256], // Form URI
+ when[256], // When job queued/started/finished
hhmmss[64]; // Time HH:MM:SS
+ snprintf(uri, sizeof(uri), "%s/jobs", job->printer->uriname);
+
switch (papplJobGetState(job))
{
case IPP_JSTATE_PENDING :
@@ -1775,16 +1493,28 @@ job_cb(pappl_job_t *job, // I - Job
papplClientHTMLPrintf(client, "
%d | %s | %s | %d | %s | ", papplJobGetID(job), papplJobGetName(job), papplJobGetUsername(job), papplJobGetImpressionsCompleted(job), when);
if (show_cancel)
- papplClientHTMLPrintf(client, " %s", job->printer->uriname, papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Cancel Job")));
+ {
+ papplClientHTMLStartForm(client, uri, false);
+ papplClientHTMLPrintf(client, "", papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Cancel Job")));
+ }
if (show_hold)
- papplClientHTMLPrintf(client, " %s", job->printer->uriname, papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Hold Job")));
+ {
+ papplClientHTMLStartForm(client, uri, false);
+ papplClientHTMLPrintf(client, "", papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Hold Job")));
+ }
if (show_release)
- papplClientHTMLPrintf(client, " %s", job->printer->uriname, papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Release Job")));
+ {
+ papplClientHTMLStartForm(client, uri, false);
+ papplClientHTMLPrintf(client, "", papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Release Job")));
+ }
if (papplJobGetState(job) >= IPP_JSTATE_ABORTED && job->filename)
- papplClientHTMLPrintf(client, " %s", job->printer->uriname, papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Reprint Job")));
+ {
+ papplClientHTMLStartForm(client, uri, false);
+ papplClientHTMLPrintf(client, "", papplJobGetID(job), papplClientGetLocString(client, _PAPPL_LOC("Reprint Job")));
+ }
papplClientHTMLPuts(client, " |
\n");
}
diff --git a/pappl/printer.c b/pappl/printer.c
index 2e2b2774..0b451a40 100644
--- a/pappl/printer.c
+++ b/pappl/printer.c
@@ -673,9 +673,6 @@ papplPrinterCreate(
snprintf(path, sizeof(path), "%s/", printer->uriname);
papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebHome, printer);
- snprintf(path, sizeof(path), "%s/cancel", printer->uriname);
- papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebCancelJob, printer);
-
snprintf(path, sizeof(path), "%s/cancelall", printer->uriname);
papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebCancelAllJobs, printer);
@@ -688,9 +685,6 @@ papplPrinterCreate(
snprintf(path, sizeof(path), "%s/config", printer->uriname);
papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebConfig, printer);
- snprintf(path, sizeof(path), "%s/hold", printer->uriname);
- papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebHoldJob, printer);
-
snprintf(path, sizeof(path), "%s/jobs", printer->uriname);
papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebJobs, printer);
@@ -702,12 +696,6 @@ papplPrinterCreate(
papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebDefaults, printer);
papplPrinterAddLink(printer, _PAPPL_LOC("Printing Defaults"), path, PAPPL_LOPTIONS_NAVIGATION | PAPPL_LOPTIONS_STATUS);
- snprintf(path, sizeof(path), "%s/release", printer->uriname);
- papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebReleaseJob, printer);
-
- snprintf(path, sizeof(path), "%s/reprint", printer->uriname);
- papplSystemAddResourceCallback(system, path, "text/html", (pappl_resource_cb_t)_papplPrinterWebReprintJob, printer);
-
if (printer->driver_data.has_supplies)
{
snprintf(path, sizeof(path), "%s/supplies", printer->uriname);