/**
 * File:		timezone_proposal.ycp
 *
 * $Id: timezone_proposal.ycp 21407 2005-02-08 12:26:50Z jsuchome $
 *
 * Author:		Klaus Kaempf <kkaempf@suse.de>
 *
 * Purpose:		Proposal function dispatcher - timezone.
 *
 *			See also file proposal-API.txt for details.
 */
{
    textdomain "country";

    import "Timezone";

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

    if ( func == "MakeProposal" )
    {
	boolean force_reset      = param["force_reset"     ]:false;
	boolean language_changed = param["language_changed"]:false;

	map m = (map) SCR::Execute( .target.bash_output, "/bin/date +%Y" );
	y2milestone ("date call: %1", m);

	if (tointeger (m["stdout"]:"0") < 2004)
	{
	    ret["raw_proposal"] = [];
	    map m = (map)SCR::Execute( .target.bash_output, "/bin/date" );
	    // error text, %1 is output of 'date' command
	    ret["warning"] = sformat( _("Time %1 is in the past.
Set a correct time before starting installation."), m["stdout"]:"" );
            ret["warning_level"] = `blocker;
	}
	else
	{
	    Timezone::windows_partition = false;
	    import "Storage";
	    if (size (Storage::GetWinPrimPartitions(Storage::GetTargetMap()))>0)
	    {
		Timezone::windows_partition = true;
		y2milestone ("windows partition found: assuming local time");
	    }

	    // Fill return map
	    ret = $[
		"raw_proposal"		: [
		    Timezone::MakeProposal (force_reset, language_changed) ],
		"language_changed"	: false
	    ];
	}
    }
    else if ( func == "AskUser" )
    {
	boolean has_next = param["has_next"]:false;

	// call some function that displays a user dialog
	// or a sequence of dialogs here:
	//
	// sequence = DummyMod::AskUser( has_next );

	symbol result = (symbol)WFM::CallFunction ("inst_timezone", [true, has_next]);

	// Fill return map

	ret = $[
		"workflow_sequence" : result,
		"language_changed"  : false
	       ];
    }
    else if ( func == "Description" )
    {
	// Fill return map.
	//
	// Static values do just nicely here, no need to call a function.

	ret =
	    $[
	      // summary item
	      "rich_text_title"	:	_("Time Zone"),
	      // menue label text
	      "menu_title"	:	_("&Time Zone"),
	      "id"		:	"timezone_stuff"
	    ];
    }

    return ret;
}
