/**
 * File:	clients/inetd_proposal.ycp
 * Package:	Configuration of inetd
 * Summary:	Proposal function dispatcher.
 * Authors:	Petr Hadraba <phadraba@suse.cz>
 *
 * $Id: inetd_proposal.ycp 20931 2005-01-25 08:18:03Z mlazar $
 *
 * Proposal function dispatcher for inetd configuration.
 */

{

textdomain "inetd";

import "Inetd";
import "Progress";

/* The main () */
y2milestone("----------------------------------------");
y2milestone("Xinetd proposal started");

string func = (string) WFM::Args(0);
map param = (map) WFM::Args(1);
map ret = $[];

/* create a textual proposal */
if(func == "MakeProposal") {
    string proposal = "";
    string warning = nil;
    symbol warning_level = nil;
    boolean force_reset = param["force_reset"]:false;

    if(force_reset || !Inetd::proposal_valid) {
	Inetd::proposal_valid = true;
	boolean po = Progress::set(false);
	Inetd::Read();
	Progress::set(po);
    }
    proposal = Inetd::Summary();
    

    ret = $[
	"preformatted_proposal" : proposal,
	"warning_level" : warning_level,
	"warning" : warning,
    ];
}
/* run the module */
else if(func == "AskUser") {
    map stored = Inetd::Export();
    symbol seq = (symbol) WFM::CallFunction("inetd", [.propose]);
    if(seq != `next) Inetd::Import(stored);
    y2debug("stored=%1",stored);
    y2debug("seq=%1",seq);
    ret = $[
	"workflow_sequence" : seq
    ];
}
/* create titles */
else if(func == "Description") {
    ret = $[
	"rich_text_title" : _("Xinetd"),
	"menu_title" : _("&Xinetd"),
	"id" : "inetd",
    ];
}
/* write the proposal */
else if(func == "Write") {
    Inetd::Write();
}
/* unknown function */
else {
    y2error("unknown function: %1", func);
}

/* Finish */
y2debug("ret=%1",ret);
y2milestone("Xinetd proposal finished");
y2milestone("----------------------------------------");
return ret;

/* EOF */
}
