diff options
Diffstat (limited to 'cgi-bin/admin.c')
-rw-r--r-- | cgi-bin/admin.c | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index a3d4d7f3b..aac69d973 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1,5 +1,5 @@ /* - * "$Id: admin.c 5360 2006-03-30 17:02:17Z mike $" + * "$Id: admin.c 5425 2006-04-18 19:59:05Z mike $" * * Administration CGI for the Common UNIX Printing System (CUPS). * @@ -506,9 +506,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */ int modify) /* I - Modify the printer? */ { int i; /* Looping var */ - int element; /* Element number */ - ipp_attribute_t *attr, /* Current attribute */ - *last; /* Last attribute */ + ipp_attribute_t *attr; /* Current attribute */ ipp_t *request, /* IPP request */ *response, /* IPP response */ *oldinfo; /* Old printer information */ @@ -855,27 +853,31 @@ do_am_printer(http_t *http, /* I - HTTP connection */ * Got the list of PPDs, see if the user has selected a make... */ - cgiSetIPPVars(response, NULL, NULL, NULL, 0); - - if (var == NULL) + if (cgiSetIPPVars(response, NULL, NULL, NULL, 0) == 0) { /* - * Let the user choose a make... + * No PPD files with this make, try again with all makes... */ - for (element = 0, attr = response->attrs, last = NULL; - attr != NULL; - attr = attr->next) - if (attr->name && strcmp(attr->name, "ppd-make") == 0) - if (last == NULL || - strcasecmp(last->values[0].string.text, - attr->values[0].string.text) != 0) - { - cgiSetArray("PPD_MAKE", element, attr->values[0].string.text); - element ++; - last = attr; - } + ippDelete(response); + + request = ippNewRequest(CUPS_GET_PPDS); + + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", + NULL, "ipp://localhost/printers/"); + + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, + "requested-attributes", NULL, "ppd-make"); + if ((response = cupsDoRequest(http, request, "/")) != NULL) + cgiSetIPPVars(response, NULL, NULL, NULL, 0); + + cgiStartHTML(title); + cgiCopyTemplateLang("choose-make.tmpl"); + cgiEndHTML(); + } + else if (!var) + { cgiStartHTML(title); cgiCopyTemplateLang("choose-make.tmpl"); cgiEndHTML(); @@ -931,7 +933,6 @@ do_am_printer(http_t *http, /* I - HTTP connection */ cgiEndHTML(); } - ippDelete(response); } else @@ -1182,7 +1183,7 @@ do_config_printer(http_t *http) /* I - HTTP connection */ ppdLocalize(ppd); - cgiStartHTML("Set Printer Options"); + cgiStartHTML(cgiText(_("Set Printer Options"))); cgiCopyTemplateLang("set-printer-options-header.tmpl"); if (ppdConflicts(ppd)) @@ -1451,7 +1452,7 @@ do_config_printer(http_t *http) /* I - HTTP connection */ if (!in || !out) { cgiSetVariable("ERROR", strerror(errno)); - cgiStartHTML("Set Printer Options"); + cgiStartHTML(cgiText(_("Set Printer Options"))); cgiCopyTemplateLang("error.tmpl"); cgiEndHTML(); @@ -1814,7 +1815,7 @@ do_config_server(http_t *http) /* I - HTTP connection */ * Show the current config file... */ - cgiStartHTML("Edit Configuration File"); + cgiStartHTML(cgiText(_("Edit Configuration File"))); printf("<!-- \"%s\" -->\n", filename); @@ -1837,10 +1838,13 @@ do_delete_class(http_t *http) /* I - HTTP connection */ const char *pclass; /* Printer class name */ - cgiStartHTML(cgiText(_("Delete Class"))); + /* + * Get form variables... + */ if (cgiGetVariable("CONFIRM") == NULL) { + cgiStartHTML(cgiText(_("Delete Class"))); cgiCopyTemplateLang("class-confirm.tmpl"); cgiEndHTML(); return; @@ -1851,6 +1855,7 @@ do_delete_class(http_t *http) /* I - HTTP connection */ "localhost", 0, "/classes/%s", pclass); else { + cgiStartHTML(cgiText(_("Delete Class"))); cgiSetVariable("ERROR", cgiText(_("Missing form variable!"))); cgiCopyTemplateLang("error.tmpl"); cgiEndHTML(); @@ -1877,6 +1882,12 @@ do_delete_class(http_t *http) /* I - HTTP connection */ ippDelete(cupsDoRequest(http, request, "/admin/")); + /* + * Show the results... + */ + + cgiStartHTML(cgiText(_("Delete Class"))); + if (cupsLastError() > IPP_OK_CONFLICT) cgiShowIPPError(_("Unable to delete class:")); else @@ -1898,10 +1909,13 @@ do_delete_printer(http_t *http) /* I - HTTP connection */ const char *printer; /* Printer printer name */ - cgiStartHTML(cgiText(_("Delete Printer"))); + /* + * Get form variables... + */ if (cgiGetVariable("CONFIRM") == NULL) { + cgiStartHTML(cgiText(_("Delete Printer"))); cgiCopyTemplateLang("printer-confirm.tmpl"); cgiEndHTML(); return; @@ -1912,6 +1926,7 @@ do_delete_printer(http_t *http) /* I - HTTP connection */ "localhost", 0, "/printers/%s", printer); else { + cgiStartHTML(cgiText(_("Delete Printer"))); cgiSetVariable("ERROR", cgiText(_("Missing form variable!"))); cgiCopyTemplateLang("error.tmpl"); cgiEndHTML(); @@ -1938,6 +1953,12 @@ do_delete_printer(http_t *http) /* I - HTTP connection */ ippDelete(cupsDoRequest(http, request, "/admin/")); + /* + * Show the results... + */ + + cgiStartHTML(cgiText(_("Delete Printer"))); + if (cupsLastError() > IPP_OK_CONFLICT) cgiShowIPPError(_("Unable to delete printer:")); else @@ -2867,5 +2888,5 @@ match_string(const char *a, /* I - First string */ /* - * End of "$Id: admin.c 5360 2006-03-30 17:02:17Z mike $". + * End of "$Id: admin.c 5425 2006-04-18 19:59:05Z mike $". */ |