/**
 * File:	include/nis_server/wizards.ycp
 * Package:	Configuration of NIS server
 * Summary:	Wizards definitions
 * Authors:	Martin Vidner <mvidner@suse.cz>
 *              Dan Vesely <dan@suse.cz>
 *
 * $Id: wizards.ycp 15717 2004-03-08 18:48:15Z lslezak $
 */

{
    textdomain "nis_server";

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

    include "nis_server/ui.ycp";

/**
 * Main workflow of the NIS server configuration
 * @return sequence result
 */
define symbol MainSequence() ``{

    map aliases = $[
	"begin"         : ``(WhatToConfigure ()),
	"exit_popup"    : ``(ExitPopup ()),
	"install"       : [``(InstallServer ()), true],
	"slave"         : ``(SlaveDialog ()),
	"query_hosts"   : ``(QueryHosts ()),
	"master"        : ``(MasterDialog ()),
	"details"       : ``(DetailsDialog ()),
	"maps"          : ``(MapsDialog ()),
	"decide"        : [``(SlaveExists ()), true],
	"master_slave"  : ``(MastersSlavesDialog ()),
	];

    map sequence = $[
	"ws_start"   : "begin",
	"begin"      : $[
	    `slave   : "install",
	    `master  : "install",
	    `finish  : `next,
	    `abort   : `abort,
	    `exit    : "exit_popup",
	    `nothing : `nothing,
	    ],
	"exit_popup" : $[
	    `exit    : `exit,
	    `back    : "begin"
	    ],
	"install"    : $[
	    `master  : "master",
	    `slave   : "slave",
	    `abort   : `abort
	    ],
	"slave"      : $[
	    `next    : "query_hosts",
	    `abort   : `abort
	    ],
	"master"     : $[
	    `next    : "decide",
	    `details : "details",
	    `abort   : `abort
	    ],
	"details"    : $[
	    `next    : "master",
	    `abort   : `abort
	    ],
	"decide"        : $[
	    `have_slave : "master_slave",
	    `none_slave : "maps",
	    `abort      : `abort
	    ],
	"master_slave" : $[
	    `next      : "maps",
	    `abort     : `abort
	    ],
	"maps"       : $[
	    `next    : "query_hosts",
	    `abort   : `abort
	    ],
	"query_hosts" : $[
	    `next     : `next,
	    `abort    : `abort
	    ],
	];

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

    return ret;
}


/**
 * Whole configuration of NIS server
 * @return sequence result
 */
define symbol NisServerSequence() ``{

    map aliases = $[
	"read"		: [ ``( ReadDialog() ), true ],
	"main"		: ``( MainSequence() ),
	"write"		: [ ``( WriteDialog() ), true ],
	"result"        : ``( ResultPopup () ),
	"error_details" : ``( DetailsPopup () ),
    ];

    map sequence = $[
	"ws_start" : "read",
	"read" : $[
	    `abort	: `abort,
	    `next	: "main"
	    ],
	"main" : $[
	    `abort	: `abort,
	    `nothing	: `nothing,
	    `next	: "write",
	    ],
	"write"       : $[
	    `next    : "result"
	    ],
	"result"     : $[
	    `ok      : `next,
	    `details : "error_details"
	    ],
	"error_details" : $[
	    `ok         : "result"
	    ],
	];

    Wizard::CreateDialog();
    Wizard::SetDesktopIcon("nis_server");
    symbol ret = Sequencer::Run(aliases, sequence);

    UI::CloseDialog();
    return ret;
}

/**
 * Whole configuration of NIS server but without reading and writing.
 * For use with autoinstallation.
 * @return sequence result
 */
define symbol NisServerAutoSequence() ``{
    // Translators: dialog caption
    string caption = _("NIS Server Configuration");
    // label
    term contents = `Label(_("Initializing..."));

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

    symbol ret = MainSequence();

    UI::CloseDialog();
    return ret;
}

/* EOF */
}
