ACC SHELL
/**
* File: include/security/complex.ycp
* Package: Security configuration
* Summary: Complex dialogs definitions
* Authors: Michal Svec <msvec@suse.cz>
*
* $Id: complex.ycp 54846 2009-01-21 09:09:53Z jsuchome $
*/
{
textdomain "security";
import "Label";
import "Security";
import "Wizard";
include "security/helps.ycp";
include "security/levels.ycp";
include "security/routines.ycp";
include "security/dialogs.ycp";
/**
* Write settings dialog
* @return `next if success, else `abort
*/
define symbol WriteDialog() ``{
Wizard::RestoreHelp(HELPS["write"]:"");
Security::AbortFunction = ``{return Security::PollAbort();};
boolean ret = Security::Write();
return ret ? `next : `abort;
}
/**
* Main dialog
* @return dialog result
*/
define any MainDialog() ``{
/* Main dialog caption */
string caption = _("Local Security Configuration");
string help = HELPS["main"]:"";
map<string,string> settings = Security::Settings;
foreach (string key, Security::do_not_test, {
settings = remove (settings, key);
});
/* Determine current settings */
any current = `custom;
maplist(string key, map level, Levels, ``{
y2debug("%1=%2", key, level);
if(level == settings)
current = key;
});
y2debug("%1=%2", current, Security::Settings);
/* Create RB group from the list of settings */
term RB = `VBox();
RB = add(RB, `VSpacing(0.5));
mapmap(string key, string name, LevelsLabels, ``{
RB = add(RB, `Left(`RadioButton(`id(key), `opt(`notify), name, key == current)));
RB = add(RB, `VSpacing(0.03));
return $[0:0];
});
RB = add(RB, `VSpacing(0.6));
/* RadioButton label */
RB = add(RB, `Left(`RadioButton(`id(`custom),`opt(`notify),_("&Custom Settings"), current == `custom)));
RB = add(RB, `VSpacing(0.5));
y2debug("RB=%1",RB);
/* Main dialog contents */
term contents = `HVCenter(
`VBox(
`HVSquash(
/* Frame caption */
`Frame( _("Security Settings"),
`HBox(`HSpacing(0.8),
`RadioButtonGroup(`id(`rb), RB),
`HSpacing(0.8))
)
),
`VSpacing(0.6)
)
);
contents = `HVCenter(`HVSquash(`HBox(`HSpacing(5),`VBox(`VSpacing(2),`ReplacePoint(`id(`rp_main),contents),`VSpacing(2)),`HSpacing(5))));
Wizard::SetContentsButtons(caption, contents, help,
Label::BackButton(), Label::OKButton());
Wizard::HideBackButton();
Wizard::SetAbortButton(`abort, Label::CancelButton());
any ret = nil;
while(true) {
any cur = UI::QueryWidget(`id(`rb), `CurrentButton);
ret = UI::UserInput();
/* abort? */
if(ret == `abort || ret == `cancel) {
if(ReallyAbort()) break;
else continue;
}
else if(ret == `back) {
break;
}
else if(ret == `next) {
/* check_* */
break;
}
else if(ret == `custom) {
continue;
}
else if(is(ret, string) || ret == `wizardTree) {
if (contains(tree_dialogs, ret))
{
// the current item has been selected, do not change to the same dialog
if (ret == "main")
{
// preselect the item if it has been unselected
if (Wizard::QueryTreeItem() != "main")
{
Wizard::SelectTreeItem("main");
}
continue;
}
// switch to another dialog
break;
}
if(!haskey(Levels, (string) ret)) {
y2error("Unexpected return code (key missing): %1", ret);
continue;
}
continue;
}
else {
y2error("Unexpected return code: %1", ret);
continue;
}
}
if(ret == `next || contains(tree_dialogs, ret)) {
any cur = UI::QueryWidget(`id(`rb), `CurrentButton);
y2debug("current=%1", current);
y2debug("cur=%1", cur);
if(cur != `custom) {
if(current != cur) {
y2debug("Level modified (%1)", cur);
Security::Settings = Levels[(string) cur]:$[];
Security::modified = true;
}
if(ret == `next) ret = `finish;
}
}
return ret;
}
/* EOF */
}
ACC SHELL 2018