ACC SHELL

Path : /usr/share/YaST2/include/firewall/
File Upload :
Current File : //usr/share/YaST2/include/firewall/dialogs.ycp

/**
 * File:        firewall/dialogs.ycp
 * Package:     Configuration YaST2 Firewall
 * Summary:     Configuration dialogs and workflow
 * Authors:     Lukas Ocilka <locilka@suse.cz>
 *
 * $Id: dialogs.ycp 54815 2009-01-20 13:55:47Z locilka $
 *
 * Configuration dialogs and workflow.
 * Both Expert and Simple.
 */
{
    textdomain "firewall";

    import "CWM";
    import "CWMServiceStart";
    import "DialogTree";
    import "Label";
    import "Mode";
    import "SuSEFirewall";
    import "Wizard";

    include "firewall/subdialogs.ycp";
    include "firewall/uifunctions.ycp";
    include "firewall/helps.ycp";
    include "firewall/summary.ycp";

    map<string,map<string,any> > widgets_handling = $[
	"auto_start_up" : CWMServiceStart::CreateAutoStartWidget ($[
	    "get_service_auto_start"	: SuSEFirewall::GetEnableService,

	    // Special function that adjusts the firewall
	    //    enabled + start (after Write())
	    //    or
	    //    disabled + stop (after Write())
	    "set_service_auto_start"	: SetEnableFirewall,

	    // TRANSLATORS: Radio selection, See #h1
	    "start_auto_button"		: _("&Enable Firewall Automatic Starting"),
	    // TRANSLATORS: Radio selection, See #h2
	    "start_manual_button"	: _("&Disable Firewall Automatic Starting"),
	    "help"			: sformat(CWMServiceStart::AutoStartHelpTemplate (),
		// TRANSLATORS: part of help text describind #h1, Do not use any shortcut
		_("Enable Firewall Automatic Starting"),
		// TRANSLATORS: part of help text describing #h2, Do not use any shortcut
		_("Disable Firewall Automatic Starting")
	    )
	]),
	"start_stop" : CWMServiceStart::CreateStartStopWidget ($[
	    "service_id"		: "SuSEfirewall2_setup",
					  // TRANSLATORS: status information
	    "service_running_label"	: _("Firewall is running"),
					  // TRANSLATORS: status information
	    "service_not_running_label"	: _("Firewall is not running"),
					  // TRANSLATORS: Push button
	    "start_now_button"		: _("&Start Firewall Now"),
					  // TRANSLATORS: Push button
	    "stop_now_button"		: _("S&top Firewall Now"),
	    "save_now_action"		: SaveAndRestart,
					  // TRANSLATORS: Push button
	    "save_now_button"		: _("Sa&ve Settings and Restart Firewall Now"),
	    "start_now_action"		: StartNow,
	    "stop_now_action"		: StopNow,
	    "help"			: sformat (CWMServiceStart::StartStopHelpTemplate (true),
		// TRANSLATORS: part of help text - push button label, NO SHORTCUT!!!
		_("Start Firewall Now"),
		// TRANSLATORS: part of help text - push button label, NO SHORTCUT!!!
		_("Stop Firewall Now"),
		// TRANSLATORS: part of help text - push button label, NO SHORTCUT!!!
		_("Save Settings and Restart Firewall Now")
	    )
	]),
	// hack function for disabling BackButton
	"DisableBackButton" : $[
	    "widget"		: `custom,
	    "custom_widget"	: `Empty(),
	    "init"		: DisableBackButton,
	    "help"		: " ",
	],
	"FirewallInterfaces" : $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitFirewallInterfaces,
	    "handle"		: HandleFirewallInterfaces,
	    //"store"		: NoStoreNeeded,
	    "help"		: HelpForDialog("firewall-interfaces"),
	],
	"AllowedServices" : $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitAllowedServices,
	    "handle"		: HandleAllowedServices,
	    //"store"		: NoStoreNeeded,
	    "help"		: HelpForDialog("allowed-services"),
	],
	"Masquerading"		: $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitMasquerading,
	    "handle"		: HandleMasquerading,
	    //"store"		: NoStoreNeeded,
	    "help"		: HelpForDialog("base-masquerading"),
	],
	"BroadcastConfigurationSimple": $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitBroadcastConfigurationSimple,
	    //"handle"		: NoHandlingNeeded,
	    "store"		: StoreBroadcastConfigurationSimple,
	    "help"		: HelpForDialog("simple-broadcast-configuration"),
	],
	"BroadcastReply": $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitBroadcastReply,
	    "handle"		: HandleBroadcastReply,
	    "help"		: HelpForDialog("broadcast-reply"),
	],
/*
	IPsec is not supported any more (no service defined by package)

	"IPsecSupport"		: $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitIPsecSupport,
	    "handle"		: HandleIPsecSupport,
	    "store"		: StoreIPsecSupport,
	    "help"		: HelpForDialog("base-ipsec-support"),
	],
*/
	"LoggingLevel"		: $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitLoggingLevel,
	    //"handle"		: NoHandlingNeeded,
	    "store"		: StoreLoggingLevel,
	    "help"		: HelpForDialog("base-logging"),
	],
	"RedirectToMasqueradedIP" : $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitRedirectToMasqueradedIP,
	    "handle"		: HandleRedirectToMasqueradedIP,
	    //"store"		: NoStoreNeeded,
	    "help"		: HelpForDialog("masquerade-redirect-table"),
	],
	"CustomRules" : $[
	    "widget"		: `custom,
	    "custom_widget"	: `VBox(),
	    "init"		: InitCustomRules,
	    "handle"		: HandleCustomRules,
	    // "store"		: NoStoreNeeded,
	    "help"		: HelpForDialog("custom-rules"),
	],
	"CheckServiceStartVsStartedStopped" : $[
	    "widget"		: `custom,
	    "custom_widget"	: `Empty(),
	    "init"		: InitServiceStartVsStartedStopped,
	    "help"		: " ",
	],
    ];

    // TRANSLATORS: Part of dialog caption
    string firewall_caption = _("Firewall Configuration");

    map<string, map<string, any> > tabs = $[
	"start_up"		: $[
	    "contents"		: `VBox (
		"auto_start_up",
		`VSpacing (1),
		// disabling start/stop buttons when it doesn't make sense
		(Mode::normal() ? "start_stop" : `Empty()),
		(Mode::normal() ? "CheckServiceStartVsStartedStopped" : `Empty()),
		`VStretch ()
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Start-Up"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Start-Up"),
	    "widget_names"	: [ "DisableBackButton", "auto_start_up", "start_stop", "CheckServiceStartVsStartedStopped" ]
	],
	"interfaces"		: $[
	    "contents"		: `VBox (
		FirewallInterfaces(),
		`VSpacing (1)
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Interfaces"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Interfaces"),
	    "widget_names"	: [ "DisableBackButton", "FirewallInterfaces" ]
	],
	"allowed_services"	: $[
	    "contents"		: `VBox (
		AllowedServices(),
		`VSpacing (1)
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Allowed Services"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Allowed Services"),
	    "widget_names"	: [ "DisableBackButton", "AllowedServices" ]
	],
	"masquerading"		: $[
	    "contents"		: `VBox (
		Masquerading(),
		`VSpacing(1),
		RedirectToMasqueradedIP(),
		`VSpacing (1)
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Network Masquerading"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Masquerading"),
	    "widget_names"	: [ "DisableBackButton", "Masquerading", "RedirectToMasqueradedIP" ]
	],
	"broadcast_simple"	: $[
	    "contents"		: `VBox (
		BroadcastConfigurationSimple(),
		`VSpacing(1),
		BroadcastReply(),
		`VStretch ()
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Broadcast"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Broadcast"),
	    "widget_names"	: [ "DisableBackButton", "BroadcastConfigurationSimple", "BroadcastReply" ]
	],
/*
	IPsec is not supported any more (no service defined by package)

	"ipsec_support"		: $[
	    "contents"		: `VBox (
		IPsecSupport(),
		`VStretch ()
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("IPsec Support"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("IPsec Support"),
	    "widget_names"	: [ "DisableBackButton", "IPsecSupport" ]
	],
*/
	"logging_level"		: $[
	    "contents"		: `VBox (
		LoggingLevel(),
		`VStretch ()
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Logging Level"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Logging Level"),
	    "widget_names"	: [ "DisableBackButton", "LoggingLevel" ]
	],
	"custom_rules"		: $[
	    "contents"          : `VBox (
		CustomFirewallRules()
	    ),
	    // TRANSLATORS: part of dialog caption
	    "caption"		: firewall_caption + ": " + _("Custom Rules"),
	    // TRANSLATORS: tree menu item
	    "tree_item_label"	: _("Custom Rules"),
	    "widget_names"	: [ "DisableBackButton", "CustomRules" ]
	]
    ];

    map<symbol,any> functions = $[
	`abort : AbortDialog,
    ];

    symbol RunFirewallDialogs () {
	list<string> simple_dialogs = [ "start_up", "interfaces", "allowed_services",
	    "masquerading", "broadcast_simple", /* "ipsec_support", */ "logging_level", "custom_rules" ];

	return DialogTree::ShowAndRun ($[
	    "ids_order"		: simple_dialogs,
	    "initial_screen"	: "start_up",
	    "screens"		: tabs,
	    "widget_descr"	: widgets_handling,
	    "back_button"	: Label::BackButton(),
	    "abort_button"	: Label::CancelButton(),
	    // if 'normal' or 'installation', [Next] button, else [OK]
	    "next_button"	: (Mode::normal() ?
		Label::NextButton () : Label::OKButton ()
	    ),
	    "functions"		: functions,
	]);
    }

    symbol BoxSummaryDialog () {
	Wizard::SetContentsButtons (
	    // TRANSLATORS: part of dialog caption
	    firewall_caption + ": " + _("Summary"),
	    BoxSummary(),
	    HelpForDialog("box-summary"),
	    Label::BackButton (),
	    (Mode::normal() ? Label::FinishButton() : Label::OKButton ())
	);
	Wizard::SetAbortButton (`abort, Label::CancelButton());
	SetFirewallIcon();
	UI::ChangeWidget(`id(`back), `Enabled, true);

	InitBoxSummary([]);

	any ret = nil;
	while (true) {
	    ret = UI::UserInput();

	    if (ret == `back || ret == `next) break;

	    // bugzilla #249777, `cancel == [x] (Closing YaST UI).
	    if ((ret == `abort || ret == `cancel) && AbortDialog() == true) {
		// ret is evaluated by the dialog sequencer
		ret = `abort;
		break;
	    }

	    if (ret == "show_details") {
		SuSEFirewallUI::SetShowSummaryDetails (
		    (boolean) UI::QueryWidget (`id ("show_details"), `Value)
		);
		InitBoxSummary([]);
	    }
	}

	return (symbol) ret;
    }
}

ACC SHELL 2018