Author: lslezak Date: Tue Aug 12 10:40:05 2008 New Revision: 49968 URL: http://svn.opensuse.org/viewcvs/yast?rev=49968&view=rev Log: - display clickable link in the Security overview dialog Modified: trunk/security/src/dialogs.ycp Modified: trunk/security/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/security/src/dialogs.ycp?rev=49968&r1=49967&r2=49968&view=diff ============================================================================== --- trunk/security/src/dialogs.ycp (original) +++ trunk/security/src/dialogs.ycp Tue Aug 12 10:40:05 2008 @@ -22,10 +22,12 @@ list tree_dialogs = [ "main", "overview", "password", "boot", "login", "users", "misc", `wizardTree ]; -string SecurityStatus(string value) +string SecurityStatus(string option) { string ret = _("Configure"); + string value = Security::Settings[option]:""; + if (value == "yes") { ret = _("Enabled"); @@ -35,6 +37,8 @@ ret = _("Disabled"); } + ret = sformat("%2</a>", option, ret); + return ret; } @@ -47,39 +51,35 @@ <TD ALIGN=center><BIG><B> %3 </B></BIG></TD> </TR> <TR></TR>", // table header - _("Security Setting"), _("Configured Status"), _("Security Status")); + _("Security Setting"), _("Status"), _("Security Status")); list<map> security_mapping = [ $[ "label" : _("Use magic SysRq keys"), - "name" : "ENABLE_SYSRQ", - "secure_value" : "no" + "link" : SecurityStatus("ENABLE_SYSRQ"), + "is_secure" : (Security::Settings["ENABLE_SYSRQ"]:"" == "no") ], $[ "label" : _("Use secure file permissions"), - "name" : "PERMISSION_SECURITY", - "secure_value" : "secure" + "link" : SecurityStatus("PERMISSION_SECURITY"), + "is_secure" : (Security::Settings["PERMISSION_SECURITY"]:"" == "secure" + || Security::Settings["PERMISSION_SECURITY"]:"" == "paranoid") ], $[ "label" : _("Remote access to the display manager"), - "name" : "DISPLAYMANAGER_REMOTE_ACCESS", - "secure_value" : "no" + "link" : SecurityStatus("DISPLAYMANAGER_REMOTE_ACCESS"), + "is_secure" : (Security::Settings["DISPLAYMANAGER_REMOTE_ACCESS"]:"" == "no") ], $[ "label" : _("Use current directory in root's path"), - "name" : "CWD_IN_ROOT_PATH", - "secure_value" : "no" + "link" : SecurityStatus("CWD_IN_ROOT_PATH"), + "is_secure" : (Security::Settings["CWD_IN_ROOT_PATH"]:"" == "no") ], $[ "label" : _("Use current directory in path of regular users"), - "name" : "CWD_IN_USER_PATH", - "secure_value" : "no" + "link" : SecurityStatus("CWD_IN_USER_PATH"), + "is_secure" : (Security::Settings["CWD_IN_USER_PATH"]:"" == "no") ], - /* $[ - "label" : _(""), - "name" : "", - "secure_value" : "" - ],*/ ]; foreach(map setting, security_mapping, @@ -89,8 +89,8 @@ // add one line for each security setting ret = ret + sformat("<TR><TD>%1 </TD><TD ALIGN=center>%2</TD><TD ALIGN=center> %3</TD></TR>", setting["label"]:"", - SecurityStatus(current_value), - (current_value == setting["secure_value"]:"") ? + setting["link"]:"", + setting["is_secure"]:false ? "<SUP><FONT COLOR=green SIZE=20>â</FONT></SUP>" : "<FONT COLOR=red SIZE=20><SUP>â</SUP></FONT>" ); } @@ -102,6 +102,19 @@ return ret; } +// mapping for "Enable" and "Disable" links +// current value -> new value +map link_value_mapping = $[ + "yes" : "no", + "no" : "yes" +]; + +// mapping for "Configure" links +// config name -> dialog name +map link_config_mapping = $[ + "PERMISSION_SECURITY" : "misc" +]; + define any OverviewDialog() { /* Boot dialog caption */ @@ -128,6 +141,35 @@ else if(ret == `back || ret == `next || contains(tree_dialogs, ret)) { break; } + // user clicked a link in the richtext + else if (is(ret, string) && haskey(Security::Settings, ret)) + { + y2milestone("Clicked %1 link", ret); + + string current_value = Security::Settings[(string)ret]:""; + + string new_value = link_value_mapping[current_value]:current_value; + + // set the new value and refresh the overview + if (haskey(link_value_mapping, current_value) && new_value != current_value) + { + y2milestone("New value for %1: %2", ret, new_value); + Security::Settings[(string)ret] = new_value; + + UI::ChangeWidget(`id(`rtext), `Value, OverviewText()); + } + else if (haskey(link_config_mapping, ret)) + { + string new_dialog = link_config_mapping[ret]:""; + + y2milestone("Switching to dialog %1", new_dialog); + return new_dialog; + } + else + { + y2error("Unknown action for link %1", ret); + } + } else { y2error("Unexpected return code: %1", ret); continue; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org