/**
 * File:	clients/CASA_proposal.ycp
 * Package:	Configuration of CASA
 * Summary:	Proposal function dispatcher.
 * Authors:	casa <casa@novell.com>
 *
 *********************************************************************
 * Copyright (C) 2005-2007 Novell, Inc. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; version 2.1
 * of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, Novell, Inc.
 *
 * To contact Novell about this file by physical or electronic mail, 
 * you may find current contact information at www.novell.com.
 *
 *********************************************************************
 *
 * Proposal function dispatcher for CASA configuration.
 * See source/installation/proposal/proposal-API.txt
 */

{

textdomain "CASA";

import "NovellCasa";
import "Progress";

/* The main () */
y2milestone("----------------------------------------");
y2milestone("CASA 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 || !NovellCasa::proposal_valid) {
//        NovellCasa::proposal_valid = true;
//	Progress::off();
//	NovellCasa::Read();
//    }
    list sum = NovellCasa::Summary();
//    proposal = sum[0]:"";
    Progress::on();

    ret = $[
//	"preformatted_proposal" : proposal,
//	"warning_level" : warning_level,
//	"warning" : warning,
    ];
}
/* run the module */
else if(func == "AskUser") {
    map stored = NovellCasa::Export();
    symbol seq = (symbol) WFM::CallFunction("CASA", [.propose]);
    if(seq != `next) NovellCasa::Import(stored);

    y2debug("stored=%1",stored);
    y2debug("seq=%1",seq);
    ret = $[
	"workflow_sequence" : seq
    ];
}
/* create titles */
else if(func == "Description") {
    ret = $[
	/* Rich text title for CASA in proposals */
	"rich_text_title" : _("CASA"),
	/* Menu title for CASA in proposals */
	"menu_title" : _("&CASA"),
	"id" : "CASA",
    ];
}
/* write the proposal */
else if(func == "Write") {
    NovellCasa::Write();
}
/* unknown function */
else {
    y2error("unknown function: %1", func);
}

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

/* EOF */
}