ACC SHELL

Path : /usr/share/YaST2/include/security/
File Upload :
Current File : //usr/share/YaST2/include/security/wizards.ycp

/**
 * File:	include/security/wizards.ycp
 * Package:	Security configuration
 * Summary:	Wizards definitions
 * Authors:	Michal Svec <msvec@suse.cz>
 *
 * $Id: wizards.ycp 54846 2009-01-21 09:09:53Z jsuchome $
 */

{

textdomain "security";

import "Label";
import "Sequencer";
import "Wizard";

include "security/complex.ycp";
include "security/dialogs.ycp";
include "security/users.ycp";

define any TreeDialog()
{
    Wizard::OpenTreeNextBackDialog();
    list<map> tree = [];

    // params: input tree, parent, label, id
    tree = Wizard::AddTreeItem(tree, "", _("Security Overview"), "overview");
    tree = Wizard::AddTreeItem(tree, "", _("Predefined Security Configurations"), "main");
    tree = Wizard::AddTreeItem(tree, "", _("Password Settings"), "password");
    tree = Wizard::AddTreeItem(tree, "", _("Boot Settings"), "boot");
    tree = Wizard::AddTreeItem(tree, "", _("Login Settings"), "login");
    tree = Wizard::AddTreeItem(tree, "", _("User Addition"), "users");
    tree = Wizard::AddTreeItem(tree, "", _("Miscellaneous Settings"), "misc");

    Wizard::CreateTree(tree, "Security");

    any ret = OverviewDialog();

    while(true)
    {
	// needed for ncurses UI
	if (ret == `wizardTree)
	{
	    ret = Wizard::QueryTreeItem();
	}

	if (ret == "main")
	{
	    ret = MainDialog();
	}
	else if (ret == "overview")
	{
	    ret = OverviewDialog();
	}
	else if (ret == "password")
	{
	    ret = PassDialog();
	}
	else if (ret == "boot")
	{
	    ret = BootDialog();
	}
	else if (ret == "login")
	{
	    ret = LoginDialog();
	}
	else if (ret == "users")
	{
	    ret = AdduserDialog();
	}
	else if (ret == "misc")
	{
	    ret = MiscDialog();
	}
	else if (ret == `next || ret == `abort || ret == `finish)
	{
	    break;
	}
	else
	{
	    y2error("Unknown return value %1, aborting...", ret);
	    ret = `abort;
	    break;
	}
    }

    Wizard::CloseDialog();

    return ret;
}

/**
 * Main workflow of the security configuration
 * @return any Returned value from WizardSequencer() call
 */
define any MainSequence() ``{

    map aliases = $[
	"main"     : ``(MainDialog()),
	"password" : ``(PassDialog()),
	"boot"     : ``(BootDialog()),
	"login"    : ``(LoginDialog()),
	"adduser"  : ``(AdduserDialog()),
	"misc"     : ``(MiscDialog()),
    ];

    map sequence = $[
	"ws_start" : "main",
	"main" : $[
	    `abort : `abort,
	    `next : "password",
	    `finish : `next,
	],
	"password" : $[
	    `abort : `abort,
	    `next : "boot"
	],
	"boot" : $[
	    `abort : `abort,
	    `next : "login"
	],
	"login" : $[
	    `abort : `abort,
	    `next : "adduser"
	],
	"adduser" : $[
	    `abort : `abort,
	    `next : "misc"
	],
	"misc" : $[
	    `abort : `abort,
	    `next : `next,
	],
    ];

    any ret = Sequencer::Run(aliases, sequence);

    return ret;
}

/**
 * Whole configuration of security
 * @return any Returned value from WizardSequencer() call
 */
define any SecuritySequence() ``{

    map aliases = $[
	"main"	:   ``( TreeDialog() ),
	"write"	: [ ``( WriteDialog() ), true ]
    ];

    map sequence = $[
	"ws_start" : "main",
	"main" : $[
	    `abort	: `abort,
	    `finish	: "write",
	    `next	: "write"
	],
	"write" : $[
	    `abort	: `abort,
	    `next	: `next
	]
    ];

    Wizard::CreateDialog();
    Wizard::SetDesktopIcon("security");

    // Read has no progress and returns only true
    Security::Read();

    any ret = Sequencer::Run(aliases, sequence);

    UI::CloseDialog();
    return ret;
}

/**
 * Whole configuration of security but without reading and writing.
 * For use with autoinstallation.
 * @return any Returned value from WizardSequencer() call
 */
define any SecurityAutoSequence() ``{

    /* Dialog caption */
    string caption = _("Security Configuration");
    /* Label */
    term contents = `Label(_("Initializing..."));

    Wizard::CreateDialog();
    Wizard::SetDesktopIcon("security");
    Wizard::SetContentsButtons(caption, contents, "",
	    Label::BackButton(), Label::NextButton());

    /* Run the main configuration workflow */
    any ret = TreeDialog();

    UI::CloseDialog();
    return ret;
}

/* EOF */
}

ACC SHELL 2018