/**
 * File:	include/ntp-client/wizards.ycp
 * Package:	Configuration of ntp-client
 * Summary:	Wizards definitions
 * Authors:	Jiri Srain <jsrain@suse.cz>
 *
 * $Id: wizards.ycp 20570 2004-12-15 13:51:14Z jsrain $
 */

{

textdomain "ntp-client";

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

include "ntp-client/dialogs.ycp";



/**
 * Complex workflow of the ntp-client configuration
 * @return sequence result
 */
define symbol ComplexSequence() ``{

    map aliases = $[
	"main"		:   ``(MainDialog ()),
	"type_select"	:   ``(TypeSelectDialog ()),
	"server"	:   ``(ServerDialog ()),
	"server_select"	:   ``(ServerSelectionDialog ()),
	"peer"		:   ``(PeerDialog ()),
	"clock"		:   ``(RadioDialog ()),
	"fudge"		:   ``(FudgeDialog ()),
	"bcast"		:   ``(BCastDialog ()),
	"bcastclient"	:   ``(BCastClientDialog ()),
	"store_record"	: [ ``(StoreRecord ()), true],
    ];

    map sequence = $[
	"ws_start" : "main",
	"main" : $[
	    `abort	: `abort,
	    `next	: `next,
	    `peer	: "peer",
	    `server	: "server",
	    `clock	: "clock",
	    `bcast	: "bcast",
	    `bcastclient: "bcastclient",
	    `add	: "type_select",
	],
	"type_select" : $[
	    `abort	: `abort,
	    `peer	: "peer",
	    `server	: "server",
	    `clock	: "clock",
	    `bcast	: "bcast",
	    `bcastclient: "bcastclient",
	],
	"peer" : $[
	    `abort	: `abort,
	    `next	: "store_record",
	],
	"server" : $[
	    `abort	: `abort,
	    `next	: "store_record",
	    `select	: "server_select",
	],
	"server_select" : $[
	    `abort	: `abort,
	    `next	: "server",
	],
	"clock" : $[
	    `abort	: `abort,
	    `next	: "store_record",
	    `fudge	: "fudge"
	],
	"fudge" : $[
	    `abort	: `abort,
	    `next	: "clock",
	],
	"bcast" : $[
	    `abort	: `abort,
	    `next	: "store_record",
	],
	"bcastclient" : $[
	    `abort	: `abort,
	    `next	: "store_record",
	],
	"store_record" : $[
	    `abort	: `abort,
	    `next	: "main",
	],
    ];

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

    return ret;
}

/**
  * The simple workflow for the NTP client
  * @return sequence result
  */
define symbol SimpleSequence () ``{

    NtpClient::selected_record = $[
	"type" : "__clock",
	"address" : "127.127.3.2",
    ];

    map aliases = $[
	"switcher"	:[``(SelectConfigType ()), true ],
	"simple_pre"	:[``(SimpleDialogPrepare ()), true ],
	"simple"	: ``(SimpleDialog ()),
	"simple_post"	:[``(SimpleDialogFinish ()), true ],
	"server_select"	: ``(ServerSelectionDialog ()),
	"complex"	: ``(ComplexSequence ()),
    ];

    map sequence = $[
	"ws_start" : "switcher",
	"switcher" : $[
	    `simple : "simple_pre",
	    `complex : "complex",
	],
	"simple_pre" : $[
	    `abort	: `abort,
	    `next	: "simple",
	],
	"simple" : $[
	    `abort	: `abort,
	    `next	: "simple_post",
	    `complex	: "complex",
	    `select	: "server_select",
	],
	"simple_post" : $[
	    `abort	: `abort,
	    `next	: `next,
	],
	"server_select" : $[
	    `abort	: `abort,
	    `next	: "simple",
	],
	"complex" : $[
	    `abort	: `abort,
	    `next	: `next,
	],
    ];

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

    return ret;
}

/**
 * Whole configuration of ntp-client
 * @return sequence result
 */
define symbol NtpClientSequence() ``{

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

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

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

    UI::CloseDialog();
    return ret;
}

/**
 * Autoyast configuration of ntp-client
 * @return sequence result
 */
define symbol NtpClientAutoSequence() ``{

    map aliases = $[
	"main"	:   ``( ComplexSequence() )
    ];

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

    // dialog caption
    string caption = _("NTP Client Configuration");
    // label
    term contents = `Label(_("Initializing ..."));

    Wizard::CreateDialog();
    Wizard::SetDesktopIcon("ntp-client");
    Wizard::SetContentsButtons(caption, contents, "",
	    Label::BackButton(), Label::NextButton());

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

    UI::CloseDialog();
    return ret;
}
/* EOF */
}
