Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
CUPS web UI should support new UIOption types (int, string, password) #1729
Comments
|
CUPS.org User: georgeliuyue Type-in value support is something that user has asked for a long time. If 1.2 has implemented PPD parsing, adding HTML support shouldn't be super difficult. |
|
CUPS.org User: georgeliuyue Can this feature be moved to CUPS 1.3 time frame? Easysoft has put in lots of effort into this feature, and CUPS 1.2 has already supported PPD parsing. With a little bit more effort, it could be visible to end users. I strongly suggest to move this feature support into 1.3. |
|
CUPS.org User: till.kamppeter Patch posted as STR #2807 (http://www.cups.org/str.php?L2807). |
|
CUPS.org User: larsuebernickel
Oh - I didn't know that. But how should this be done without JavaScript? Should all custom options be shown all the time, even if the user did not select the "Custom" entry for the option? Should the page be reloaded every time the user chooses "Custom" in for one of the options? I think there are many people who do not access the webinterface through a text-only browser. For those, the js version is superior to any of the approaches above. Do you think we could leave the JavaScript version in there? Could be as a compile time option for CUPS or even a hybrid approach based on the browser identification. |
|
CUPS.org User: mike One option would be to show the custom option fields by default and then have javascript that hides them until "Custom" is chosen. That will allow the text-only browser to continue working as before while providing a better UI for Javascript-capable browsers. BTW, this isn't just limited to text-only browsers; all versions of Firefox with the NoScript plug-in will block the javascript on the CUPS web interface by default. We don't want a lot of bug reports saying "I can't set the custom option values"... :) |
|
CUPS.org User: georgeliuyue I'd like to further propose a new syntax to specify allowed characters for string and password type PPD options. A password type with allowe chars "0-9" is equivalent to passcode type. |
|
CUPS.org User: mike George, Please file a separate feature request for the extended string/password option support. This bug only covers the web interface. |
|
CUPS.org User: larsuebernickel Mike, I've done as you've suggested - JavaScript now hides the custom parameters after the page has been loaded. For browsers which don't understand JavaScript, the parameters are always shown. I've tested with lynx and Firefox's NoScript extension. New patch is attached. It works fine against current svn (r7549). Can we still get this into 1.4? Or is it already past feature freeze?
|
|
CUPS.org User: larsuebernickel Oops, already found a small bug. Custom option parameters were hidden even if the option was set to "Custom". Fixed in r3.
|
|
CUPS.org User: mike OK, after looking at the patch, it still needs a lot of work - there is no input validation for the custom values, and custom page sizes in particular do not have any way to specify units so users would have to enter points (not too user-friendly...) Anyways, I'm working on that part and will likely stick with your HTML changes with a few minor fixes (remove XMLisms and add comments around javascript code so it doesn't get displayed...) |
|
CUPS.org User: mike Fixed in Subversion repository. |
|
"cups-expose-coptions-r2.patch": Index: doc/cups.css--- doc/cups.css (revision 7549) +TH.sublabel {
HR {
|
| {paramtext}: | - - |
|---|
+/*
- * 'get_coption_value_string' - Create the value string for the custom
- * parameters of an option.
- /
+static void
+get_coption_value_string(char *valstr, / O - Resulting value string */ -
size_t size, /\* I - Maximum size of valstr */ -
+{ppd_coption_t _opt) /_ I - Option */ - ppd_cparam_t *cparam;
- size_t pos;
- char keyword[2*PPD_MAX_NAME];
- const char *var, *var2;
- if (!strcmp(opt->keyword, "PageSize"))
- {
- var = cgiGetVariable("PageSize.Width");
- var2 = cgiGetVariable("PageSize.Height");
- snprintf(valstr, size, "Custom.%sx%s", var ? var : "0", var2 ? var2 : "0");
- }
- else if (cupsArrayCount(opt->params) == 1)
- {
- cparam =ppdFirstCustomParam(opt);
- snprintf(keyword, 2*PPD_MAX_NAME, "%s.%s", opt->keyword, cparam->name);
- var = cgiGetVariable(keyword);
- if (var)
-
snprintf(valstr, size, "Custom.%s", var); - }
- else if (cupsArrayCount(opt->params) >= 1)
- {
- valstr[0] = '{';
- for (cparam = ppdFirstCustomParam(opt), pos = 1;
- cparam && pos < size;
- cparam = ppdNextCustomParam(opt))
- {
-
snprintf(keyword, 2 \* PPD_MAX_NAME, "%s.%s", opt->keyword, cparam->name); -
var = cgiGetVariable(keyword); -
if (!var) - continue;
-
pos += snprintf(&valstr[pos], size - pos, "%s=%s, ", cparam->name, var); - }
- /* Remove the last ',' */
- if (pos > 3)
-
strlcpy(&valstr[pos -3], "}", size); - }
+}
/*
- 'do_set_options()' - Configure the default options for a queue.
/
@@ -2780,10 +2828,12 @@
ppd_file_t *ppd; / PPD file /
ppd_group_t *group; / Option group /
ppd_option_t *option; / Option */ - ppd_coption_t coption; / Custom Option */
- ppd_cparam_t cparam; / Custom param /
ppd_attr_t *protocol; / cupsProtocol attribute /
const char *title; / Page title */ - char tmp[1024];
title = cgiText(is_class ? _("Set Class Options") : _("Set Printer Options"));
fprintf(stderr, "DEBUG: do_set_options(http=%p, is_class=%d)\n", http,
@@ -2928,7 +2978,7 @@
cgiSetVariable("KEYWORD", option->keyword);
cgiSetVariable("KEYTEXT", option->text);
-
- if (option->conflicted)
cgiSetVariable("CONFLICTED", "1");
else
@@ -2938,13 +2988,6 @@
cgiSetSize("TEXT", 0);
for (k = 0, m = 0; k < option->num_choices; k ++)
{
- if (option->conflicted)
-
/* -
\* Hide custom option values...
- */
-
if (!strcmp(option->choices[k].choice, "Custom"))
- continue;
cgiSetArray("CHOICES", m, option->choices[k].choice);
cgiSetArray("TEXT", m, option->choices[k].text);
@@ -2954,6 +2997,64 @@
cgiSetVariable("DEFCHOICE", option->choices[k].choice);
}
-
cgiSetSize("PARAMS", 0); -
cgiSetSize("PARAMTEXT", 0); -
cgiSetSize("PARAMVALUE", 0); -
cgiSetSize("INPUTTYPE", 0); -
if ((coption = ppdFindCustomOption(ppd, option->keyword))) -
{ -
cgiSetVariable("ISCUSTOM", "1"); -
/* -
\* TODO Can these be traversed sorted by their order? (The params -
\* for PageSize gets all messed up this way) -
*/ -
for (cparam = ppdFirstCustomParam(coption), m = 0; -
cparam; -
cparam = ppdNextCustomParam(coption)) -
{ -
cgiSetArray("PARAMS", m, cparam->name); -
cgiSetArray("PARAMTEXT", m, cparam->text); -
switch (cparam->type) { -
case PPD_CUSTOM_CURVE: -
case PPD_CUSTOM_INVCURVE: -
case PPD_CUSTOM_REAL: -
case PPD_CUSTOM_POINTS: -
snprintf(tmp, 50, "%f", cparam->current.custom_real); -
cgiSetArray("PARAMVALUE", m, tmp); -
cgiSetArray("INPUTTYPE", m, "text"); -
break; -
case PPD_CUSTOM_INT: -
snprintf(tmp, 50, "%d", cparam->current.custom_int); -
cgiSetArray("PARAMVALUE", m, tmp); -
cgiSetArray("INPUTTYPE", m, "text"); -
break; -
case PPD_CUSTOM_PASSCODE: -
case PPD_CUSTOM_PASSWORD: -
if (cparam->current.custom_password) -
cgiSetArray("PARAMVALUE", m, cparam->current.custom_password); -
else -
cgiSetArray("PARAMVALUE", m, ""); -
cgiSetArray("INPUTTYPE", m, "password"); -
break; -
case PPD_CUSTOM_STRING: -
if (cparam->current.custom_string) -
cgiSetArray("PARAMVALUE", m, cparam->current.custom_string); -
else -
cgiSetArray("PARAMVALUE", m, ""); -
cgiSetArray("INPUTTYPE", m, "text"); -
break; -
} -
m++; -
} -
} -
else -
cgiSetVariable("ISCUSTOM", "0");- switch (option->ui)
{
case PPD_UI_BOOLEAN :
@@ -2967,8 +3068,14 @@
break;
}
}
- switch (option->ui)
- cgiCopyTemplateLang("option-trailer.tmpl");
- cgiCopyTemplateLang("option-trailer.tmpl");
- /* Clear some cgi vars (for future options) */
- cgiSetVariable("ISCUSTOM", "0");
- cgiSetSize("PARAMS", 0);
- cgiSetSize("PARAMTEXT", 0);
- cgiSetSize("PARAMVALUE", 0);
- cgiSetSize("INPUTTYPE", 0);
}
}
@@ -3203,10 +3310,15 @@
else
var = cgiGetVariable(keyword);
-
if (var != NULL) -
if (var == NULL) -
cupsFilePrintf(out, "%s\n", line); -
else if (!strcmp(var, "Custom") && (coption = ppdFindCustomOption(ppd, keyword))) -
{ -
get_coption_value_string(tmp, 1024, coption); -
cupsFilePrintf(out, "*Default%s: %s\n", keyword, tmp); -
} -
else cupsFilePrintf(out, "*Default%s: %s\n", keyword, var); -
else -
}cupsFilePrintf(out, "%s\n", line);
}
|
"cups-expose-coptions-r3.patch": diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c +/*
/*
title = cgiText(is_class ? _("Set Class Options") : _("Set Printer Options")); @@ -2928,7 +2978,7 @@ do_set_options(http_t http, / I - HTTP connection */
- */
- continue;
@@ -2954,6 +2997,64 @@ do_set_options(http_t http, / I - HTTP connection */
@@ -3203,10 +3310,15 @@ do_set_options(http_t http, / I - HTTP connection */
diff --git a/doc/cups.css b/doc/cups.css +TH.sublabel {
HR {
|
|
"str1729.patch": Index: doc/cups.css--- doc/cups.css (revision 7797) +TH.sublabel {
HR { Index: CHANGES.txt--- CHANGES.txt (revision 7800) CHANGES IN CUPS V1.4b1
@@ -43,6 +45,7 @@ /*
@@ -177,7 +183,7 @@
@@ -2847,32 +2856,14 @@
- "
|
michaelrsweet commentedMay 27, 2006
Version: 1.4-feature
CUPS.org User: georgeliuyue
If the web ui of CUPS 1.2 could support input types (int, string, password), that will make the new UIOption features in CUPS 1.2 really useful.