summaryrefslogtreecommitdiff
path: root/cgi-bin
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2008-09-29 17:17:42 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2008-09-29 17:17:42 +0000
commit1f6f3dbcf92ae4c7e22a6b143ef27dd330e8ddbb (patch)
tree2bd75a648fdfc2bcb00b506378bfac8b62cceeee /cgi-bin
parent0af14961a854522d785f6716459b8fb951632963 (diff)
Merge changes from CUPS 1.4svn-r7994.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@989 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cgi-bin')
-rw-r--r--cgi-bin/admin.c124
1 files changed, 116 insertions, 8 deletions
diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c
index 3dea06ded..70a57dc5e 100644
--- a/cgi-bin/admin.c
+++ b/cgi-bin/admin.c
@@ -910,7 +910,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */
*/
if (strncmp(attr->values[0].string.text, var, strlen(var)) == 0)
- cgiSetVariable("DEVICE_URI", attr->values[0].string.text);
+ cgiSetVariable("CURRENT_DEVICE_URI", attr->values[0].string.text);
}
/*
@@ -957,7 +957,15 @@ do_am_printer(http_t *http, /* I - HTTP connection */
*/
if (oldinfo)
- cgiSetIPPVars(oldinfo, NULL, NULL, NULL, 0);
+ {
+ if ((attr = ippFindAttribute(oldinfo, "printer-info",
+ IPP_TAG_TEXT)) != NULL)
+ cgiSetVariable("PRINTER_INFO", attr->values[0].string.text);
+
+ if ((attr = ippFindAttribute(oldinfo, "printer-location",
+ IPP_TAG_TEXT)) != NULL)
+ cgiSetVariable("PRINTER_LOCATION", attr->values[0].string.text);
+ }
cgiCopyTemplateLang("modify-printer.tmpl");
}
@@ -1417,9 +1425,9 @@ do_config_server(http_t *http) /* I - HTTP connection */
/* PreserveJobHistory value */
*preserve_job_files,
/* PreserveJobFiles value */
+ *max_clients, /* MaxClients value */
*max_jobs, /* MaxJobs value */
- *max_log_size, /* MaxLogSize value */
- *val; /* Value for other setting */
+ *max_log_size; /* MaxLogSize value */
char local_protocols[255],
/* BrowseLocalProtocols */
remote_protocols[255];
@@ -1427,6 +1435,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
#ifdef HAVE_GSSAPI
char default_auth_type[255];
/* DefaultAuthType value */
+ const char *val; /* Setting value */
#endif /* HAVE_GSSAPI */
@@ -1451,9 +1460,13 @@ do_config_server(http_t *http) /* I - HTTP connection */
browse_web_if = cgiGetVariable("BROWSE_WEB_IF") ? "Yes" : "No";
preserve_job_history = cgiGetVariable("PRESERVE_JOB_HISTORY") ? "Yes" : "No";
preserve_job_files = cgiGetVariable("PRESERVE_JOB_FILES") ? "Yes" : "No";
+ max_clients = cgiGetVariable("MAX_CLIENTS");
max_jobs = cgiGetVariable("MAX_JOBS");
max_log_size = cgiGetVariable("MAX_LOG_SIZE");
+ if (!max_clients || atoi(max_clients) <= 0)
+ max_clients = "100";
+
if (!max_jobs || atoi(max_jobs) <= 0)
max_jobs = "500";
@@ -1547,7 +1560,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
{
val = cupsGetOption("DefaultAuthType", num_settings, settings);
- if (val && !strcasecmp(val, "Negotiate"))
+ if (!val || !strcasecmp(val, "Negotiate"))
strlcpy(default_auth_type, "Basic", sizeof(default_auth_type));
else
strlcpy(default_auth_type, val, sizeof(default_auth_type));
@@ -1592,6 +1605,8 @@ do_config_server(http_t *http) /* I - HTTP connection */
strcasecmp(preserve_job_history, "Yes") ||
cupsGetOption("PreserveJobFiles", num_settings, settings) ||
strcasecmp(preserve_job_files, "No") ||
+ cupsGetOption("MaxClients", num_settings, settings) ||
+ strcasecmp(max_clients, "100") ||
cupsGetOption("MaxJobs", num_settings, settings) ||
strcasecmp(max_jobs, "500") ||
cupsGetOption("MaxLogSize", num_settings, settings) ||
@@ -1650,6 +1665,10 @@ do_config_server(http_t *http) /* I - HTTP connection */
strcasecmp(preserve_job_files, "No"))
num_settings = cupsAddOption("PreserveJobFiles", preserve_job_files,
num_settings, &settings);
+ if (cupsGetOption("MaxClients", num_settings, settings) ||
+ strcasecmp(max_clients, "100"))
+ num_settings = cupsAddOption("MaxClients", max_clients, num_settings,
+ &settings);
if (cupsGetOption("MaxJobs", num_settings, settings) ||
strcasecmp(max_jobs, "500"))
num_settings = cupsAddOption("MaxJobs", max_jobs, num_settings,
@@ -2584,6 +2603,11 @@ do_menu(http_t *http) /* I - HTTP connection */
cgiSetVariable("PRESERVE_JOB_FILES", "CHECKED");
}
+ if ((val = cupsGetOption("MaxClients", num_settings, settings)) == NULL)
+ val = "100";
+
+ cgiSetVariable("MAX_CLIENTS", val);
+
if ((val = cupsGetOption("MaxJobs", num_settings, settings)) == NULL)
val = "500";
@@ -2860,6 +2884,9 @@ do_set_allowed_users(http_t *http) /* I - HTTP connection */
while (*ptr == ',' || isspace(*ptr & 255))
ptr ++;
+ if (!*ptr)
+ break;
+
if (*ptr == '\'' || *ptr == '\"')
{
/*
@@ -2925,6 +2952,9 @@ do_set_allowed_users(http_t *http) /* I - HTTP connection */
while (*ptr == ',' || isspace(*ptr & 255))
ptr ++;
+ if (!*ptr)
+ break;
+
if (*ptr == '\'' || *ptr == '\"')
{
/*
@@ -3041,7 +3071,7 @@ do_set_options(http_t *http, /* I - HTTP connection */
ppd_option_t *option; /* Option */
ppd_coption_t *coption; /* Custom option */
ppd_cparam_t *cparam; /* Custom parameter */
- ppd_attr_t *protocol; /* cupsProtocol attribute */
+ ppd_attr_t *ppdattr; /* PPD attribute */
const char *title; /* Page title */
@@ -3070,6 +3100,67 @@ do_set_options(http_t *http, /* I - HTTP connection */
fprintf(stderr, "DEBUG: printer=\"%s\", uri=\"%s\"...\n", printer, uri);
/*
+ * If the user clicks on the Auto-Configure button, send an AutoConfigure
+ * command file to the printer...
+ */
+
+ if (cgiGetVariable("AUTOCONFIGURE"))
+ {
+ int job_id; /* Command file job */
+ char refresh[1024]; /* Refresh URL */
+ http_status_t status; /* Document status */
+ static const char *autoconfigure =/* Command file */
+ "#CUPS-COMMAND\n"
+ "AutoConfigure\n";
+
+
+ if ((job_id = cupsCreateJob(CUPS_HTTP_DEFAULT, printer, "Auto-Configure",
+ 0, NULL)) < 1)
+ {
+ cgiSetVariable("ERROR", cgiText(_("Unable to send auto-configure command "
+ "to printer driver!")));
+ cgiStartHTML(title);
+ cgiCopyTemplateLang("error.tmpl");
+ cgiEndHTML();
+ return;
+ }
+
+ status = cupsStartDocument(CUPS_HTTP_DEFAULT, printer, job_id,
+ "AutoConfigure.command", CUPS_FORMAT_COMMAND, 1);
+ if (status == HTTP_CONTINUE)
+ status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, autoconfigure,
+ strlen(autoconfigure));
+ if (status == HTTP_CONTINUE)
+ cupsFinishDocument(CUPS_HTTP_DEFAULT, printer);
+
+ if (cupsLastError() >= IPP_REDIRECTION_OTHER_SITE)
+ {
+ cgiSetVariable("ERROR", cupsLastErrorString());
+ cgiStartHTML(title);
+ cgiCopyTemplateLang("error.tmpl");
+ cgiEndHTML();
+
+ cupsCancelJob(printer, job_id);
+ return;
+ }
+
+ /*
+ * Redirect successful updates back to the printer page...
+ */
+
+ cgiFormEncode(uri, printer, sizeof(uri));
+ snprintf(refresh, sizeof(refresh), "5;URL=/admin/?OP=redirect&URL=/%s/%s",
+ is_class ? "classes" : "printers", uri);
+ cgiSetVariable("refresh_page", refresh);
+
+ cgiStartHTML(title);
+
+ cgiCopyTemplateLang("printer-configured.tmpl");
+ cgiEndHTML();
+ return;
+ }
+
+ /*
* Get the PPD file...
*/
@@ -3126,6 +3217,23 @@ do_set_options(http_t *http, /* I - HTTP connection */
fputs("DEBUG: Showing options...\n", stderr);
+ if (ppd)
+ {
+ if (ppd->num_filters == 0 ||
+ ((ppdattr = ppdFindAttr(ppd, "cupsCommands", NULL)) != NULL &&
+ ppdattr->value && strstr(ppdattr->value, "AutoConfigure")))
+ cgiSetVariable("HAVE_AUTOCONFIGURE", "YES");
+ else
+ {
+ for (i = 0; i < ppd->num_filters; i ++)
+ if (!strncmp(ppd->filters[i], "application/vnd.cups-postscript", 31))
+ {
+ cgiSetVariable("HAVE_AUTOCONFIGURE", "YES");
+ break;
+ }
+ }
+ }
+
cgiStartHTML(cgiText(_("Set Printer Options")));
cgiCopyTemplateLang("set-printer-options-header.tmpl");
@@ -3458,7 +3566,7 @@ do_set_options(http_t *http, /* I - HTTP connection */
if (ppd && ppd->protocols && strstr(ppd->protocols, "BCP"))
{
- protocol = ppdFindAttr(ppd, "cupsProtocol", NULL);
+ ppdattr = ppdFindAttr(ppd, "cupsProtocol", NULL);
cgiSetVariable("GROUP", cgiText(_("PS Binary Protocol")));
cgiCopyTemplateLang("option-header.tmpl");
@@ -3481,7 +3589,7 @@ do_set_options(http_t *http, /* I - HTTP connection */
cgiSetVariable("KEYWORD", "protocol");
cgiSetVariable("KEYTEXT", cgiText(_("PS Binary Protocol")));
- cgiSetVariable("DEFCHOICE", protocol ? protocol->value : "None");
+ cgiSetVariable("DEFCHOICE", ppdattr ? ppdattr->value : "None");
cgiCopyTemplateLang("option-pickone.tmpl");