Author: gs Date: Wed Oct 29 13:43:23 2008 New Revision: 52659 URL: http://svn.opensuse.org/viewcvs/yast?rev=52659&view=rev Log: add extra input fields to specify a script, rearrange some widgets Modified: trunk/audit-laf/src/complex.ycp trunk/audit-laf/src/dialogs.ycp trunk/audit-laf/src/wizards.ycp Modified: trunk/audit-laf/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/audit-laf/src/complex.ycp?rev=52659&r1=52658&r2=52659&view=diff ============================================================================== --- trunk/audit-laf/src/complex.ycp (original) +++ trunk/audit-laf/src/complex.ycp Wed Oct 29 13:43:23 2008 @@ -94,7 +94,6 @@ UI::ChangeWidget( `id("num_logs"), `Value, tointeger( AuditLaf::GetAuditdOption("num_logs")) ); foreach (string key, ["log_file", "max_log_file", - "action_mail_acct", "name" ], { UI::ChangeWidget(`id(key), `Value, (AuditLaf::GetAuditdOption(key))); @@ -120,7 +119,7 @@ if ( action == "select_file" ) { string file_name = UI::AskForSaveFileName("/var/log/audit", "*.log", _("Select the log file") ); - + y2milestone( "Filename: %1", file_name ); UI::ChangeWidget( `id("log_file"), `Value, file_name ); y2milestone( "Logfile set to: %1", file_name ); } @@ -143,7 +142,6 @@ "max_log_file", "flush", "max_log_file_action", - "action_mail_acct", "name_format", "name" ], { @@ -208,38 +206,100 @@ // Set all values to values read from /etc/audit/auditd.conf foreach (string key, ["space_left", + "action_mail_acct", "admin_space_left" ], { UI::ChangeWidget(`id(key), `Value, (AuditLaf::GetAuditdOption(key))); }); - foreach (string key, ["space_left_action", - "admin_space_left_action", - "disk_full_action", - "disk_error_action" - ], { - UI::ChangeWidget(`id(key), `Value, toupper(AuditLaf::GetAuditdOption(key)) ); - }); + foreach ( string key, ["space_left_action", + "admin_space_left_action", + "disk_full_action", + "disk_error_action" + ], { + + if ( toupper(substring( AuditLaf::GetAuditdOption(key), 0, 4 ) ) == "EXEC" ) + { + UI::ChangeWidget( `id(key), `Value, "EXEC" ); + UI::ChangeWidget( `id(key+"_exec"), `Enabled, true ); + UI::ChangeWidget( `id(key+"_exec"), `Value, substring( AuditLaf::GetAuditdOption(key), 4 ) ); + } + else + { + UI::ChangeWidget( `id(key), `Value, toupper(AuditLaf::GetAuditdOption(key)) ); + UI::ChangeWidget( `id(key+"_exec"), `Enabled, false ); + } + }); - y2milestone( "Init disk space settings" ); + +} + +/* + * Handle actions of disk space + */ +symbol HandleDiskspaceSettingsDialog(string id, map event) { + any action = event["ID"]:nil; + y2milestone( "action: %1", action ); + + list actions_list = ["space_left_action", + "admin_space_left_action", + "disk_full_action", + "disk_error_action" + ]; + + if ( is( action, string ) && contains( actions_list, (string)action) ) + { + string option = (string)UI::QueryWidget(`id((string)action), `Value ); + y2milestone( "Option: %1", option ); + + if ( option == "EXEC" ) + { + UI::ChangeWidget( `id((string)action+"_exec"), `Enabled, true ); + } + else + { + UI::ChangeWidget( `id((string)action+"_exec"), `Enabled, false ); + } + } + + return nil; } /* * Store all settings made in disk space dialog */ void StoreDiskspaceSettingsDialog (string id, map event) { + string option = ""; + string exec = ""; + AuditLaf::SetModified( true ); - foreach (string key, ["space_left", - "admin_space_left", - "space_left_action", - "admin_space_left_action", - "disk_full_action", - "disk_error_action" + foreach ( string key, ["space_left", + "action_mail_acct", + "admin_space_left" ], { - AuditLaf::SetAuditdOption( key, (string) UI::QueryWidget(`id(key), `Value) ); - }); + AuditLaf::SetAuditdOption( key, (string) UI::QueryWidget(`id(key), `Value) ); + }); + + foreach ( string key, ["space_left_action", + "admin_space_left_action", + "disk_full_action", + "disk_error_action" + ], { + + option = (string)UI::QueryWidget( `id(key), `Value ); + if ( option == "EXEC" ) + { + exec = (string)UI::QueryWidget( `id(key+"_exec"), `Value ); + AuditLaf::SetAuditdOption( key, option + " " + exec ); + } + + else + { + AuditLaf::SetAuditdOption( key, option ); + } + }); y2milestone( "Store disk space settings" ); } Modified: trunk/audit-laf/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/audit-laf/src/dialogs.ycp?rev=52659&r1=52658&r2=52659&view=diff ============================================================================== --- trunk/audit-laf/src/dialogs.ycp (original) +++ trunk/audit-laf/src/dialogs.ycp Wed Oct 29 13:43:23 2008 @@ -69,8 +69,7 @@ ]) ), `HSpacing(2.0), - // InputField label - `HWeight( 1, `IntField(`id("num_logs"), `opt(`hstretch), _("&Number of Log Files"), 0, 99, 4) ) + `HWeight( 1, `Empty() ) ), `HBox( // ComboBox label - select how to flush data on disk @@ -107,7 +106,7 @@ ), `HSpacing(2.0), // InputField label - `HWeight( 1, `InputField(`id("action_mail_acct"), _("Action Mail Account"))) + `HWeight( 1, `IntField(`id("num_logs"), `opt(`hstretch), _("&Number of Log Files"), 0, 99, 4) ) ) ), `VStretch(), @@ -166,6 +165,23 @@ ); } +list actions_list = [`item(`id("IGNORE"), "IGNORE" ), + `item(`id("SYSLOG"), "SYSLOG", true ), + `item(`id("SUSPEND"), "SUSPEND" ), + `item(`id("SINGLE"), "SINGLE" ), + `item(`id("HALT"), "HALT" ), + `item(`id("EXEC"), "EXEC" ), + `item(`id("EMAIL"), "EMAIL" ) + ]; + +list error_actions_list = [`item(`id("IGNORE"), "IGNORE" ), + `item(`id("SYSLOG"), "SYSLOG", true ), + `item(`id("SUSPEND"), "SUSPEND" ), + `item(`id("SINGLE"), "SINGLE" ), + `item(`id("HALT"), "HALT" ), + `item(`id("EXEC"), "EXEC" ) + ]; + term DiskspaceSettingsDialogContent () { return `MarginBox( mbox_x, mbox_y, `VBox( @@ -177,69 +193,57 @@ // InputField label - space on disk is starting to run low if the entered value is reached `HWeight( 1, `InputField(`id("space_left"), _("&Space Left on Disk (MB)") )), `HSpacing(2.0), - `HWeight( 1, `ComboBox(`id("space_left_action"), `opt(`editable), + `HWeight( 1, `ComboBox(`id("space_left_action"), `opt(`notify), // ComboBox label - select an action which is performed if space on disk is low - _("&Action"), - [`item(`id("IGNORE"), "IGNORE" ), - `item(`id("SYSLOG"), "SYSLOG", true ), - `item(`id("SUSPEND"), "SUSPEND" ), - `item(`id("SINGLE"), "SINGLE" ), - `item(`id("HALT"), "HALT" ), - `item(`id("EXEC"), "EXEC" ), - `item(`id("EMAIL"), "EMAIL" ) - ]) - ) + _("&Action"), actions_list ) + ), + `HSpacing(1.0), + // InputField label - enter the path to a script (which will be executed) + `HWeight( 1, `InputField(`id("space_left_action_exec"), _("Path to Script" ) ) ) ) ), `VStretch(), - `Frame ( + `Frame( // Frame label - keep it short! _("Value and Action for Space is Running Low"), `HBox( - // InputField label - space on disk is running low if the entered value is reached - `HWeight( 1, `InputField(`id("admin_space_left"), _("&Admin Space Left on Disk (MB) ")) ), + // InputField label - space on disk is running low if the entered value is reached + `HWeight( 1, `InputField(`id("admin_space_left"), _("&Admin Space Left (MB) ")) ), `HSpacing(2.0), - `HWeight( 1, `ComboBox(`id("admin_space_left_action"), `opt(`editable), - // ComboBox label - select an action which is performed if space on disk is running low - _("Ac&tion"), - [`item(`id("IGNORE"), "IGNORE" ), - `item(`id("SYSLOG"), "SYSLOG", true ), - `item(`id("SUSPEND"), "SUSPEND" ), - `item(`id("SINGLE"), "SINGLE" ), - `item(`id("HALT"), "HALT" ), - `item(`id("EXEC"), "EXEC" ), - `item(`id("EMAIL"), "EMAIL" ) - ]) ) - + `HWeight( 1, `ComboBox(`id("admin_space_left_action"), `opt(`notify), + // ComboBox label - select an action which is performed if space on disk is running low + _("Ac&tion"), actions_list ) + ), + `HSpacing(1.0), + // InputField label - enter the path to a script (which will be executed) + `HWeight( 1, `InputField(`id("admin_space_left_action_exec"), _("Path to Script" ) ) ) ) ), `VStretch(), + `InputField(`id("action_mail_acct"), _("Action Mail Account")), + `VStretch(), `Frame( // Frame label - keep it short! _("Action on Error or Disk Full"), `VBox( - `ComboBox(`id("disk_full_action"), `opt(`editable, `hstretch), - // ComboBox label - select an action which is performed if disk is full - _("Disk &Full Action"), - [`item(`id("IGNORE"), "IGNORE" ), - `item(`id("SYSLOG"), "SYSLOG", true ), - `item(`id("SUSPEND"), "SUSPEND" ), - `item(`id("SINGLE"), "SINGLE" ), - `item(`id("HALT"), "HALT" ), - `item(`id("EXEC"), "EXEC" ) - ]), - `ComboBox(`id("disk_error_action"), `opt(`editable, `hstretch ), - // ComboBox label - select an action which is performed on error - _("Disk &Error Action"), - [`item(`id("IGNORE"), "IGNORE" ), - `item(`id("SYSLOG"), "SYSLOG", true ), - `item(`id("SUSPEND"), "SUSPEND" ), - `item(`id("SINGLE"), "SINGLE" ), - `item(`id("HALT"), "HALT" ), - `item(`id("EXEC"), "EXEC" ) - ]) + `HBox( + `HWeight( 1, `ComboBox(`id("disk_full_action"), `opt(`notify), + // ComboBox label - select an action which is performed if disk is full + _("Disk &Full Action"), error_actions_list ) ), + `HSpacing(2.0), + // InputField label - enter the path to a script (which will be executed) + `HWeight( 1, `InputField(`id("disk_full_action_exec"), _("Path to Script" ) ) ) + ), + `HBox( + `HWeight ( 1, `ComboBox(`id("disk_error_action"), `opt(`notify ), + // ComboBox label - select an action which is performed on error + _("Disk &Error Action"), error_actions_list ) ), + `HSpacing(2.0), + // InputField label - enter the path to a script (which will be executed) + `HWeight( 1, `InputField(`id("disk_error_action_exec"), _("Path to Script" ) ) ) + ) ) - ), + ), `VStretch() ) ); Modified: trunk/audit-laf/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/audit-laf/src/wizards.ycp?rev=52659&r1=52658&r2=52659&view=diff ============================================================================== --- trunk/audit-laf/src/wizards.ycp (original) +++ trunk/audit-laf/src/wizards.ycp Wed Oct 29 13:43:23 2008 @@ -66,6 +66,7 @@ "help" : HELPS["diskspace_settings"]:"", "custom_widget" : DiskspaceSettingsDialogContent(), "init" : InitDiskspaceSettingsDialog, + "handle" : HandleDiskspaceSettingsDialog, "store" : StoreDiskspaceSettingsDialog, ], "rules" : $[ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org