/**
 * File:	clients/sound_proposal.ycp
 * Package:	Sound configuration
 * Summary:	Proposal function dispatcher
 * Authors:	Dan Meszaros <dmeszar@suse.cz>
 *		Ladislav Slezak <lslezak@suse.cz>
 *
 * $Id: sound_proposal.ycp 12896 2003-12-02 15:02:54Z jsuchome $
 *
 * Proposal function dispatcher for sound configuration.
 */

{

    textdomain "sound";

    import "Sound";
    import "Progress";

    Sound::installation = true;

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

    // Make proposal for installation/configuration...
    if ( func == "MakeProposal" )
    {
	boolean force_reset = param["force_reset"]:false;

	if (force_reset)
	{
	    Sound::ForceReset();
	}

	// Do not show any progress during Read()
	Progress::off ();
	UI::OpenDialog(`VBox(`Label(_("Detecting sound cards..."))));
	boolean success = Sound::Propose ();
	UI::CloseDialog();
	Progress::on ();


	string proposal = Sound::Summary ();

	// Fill return map
	ret =
	    $[ "preformatted_proposal" : proposal,
	       "warning"               : nil, //_("Sound cards."),
	       "warning_level"         : nil //`notice
	    ];
    }
    // Run an interactive workflow
    else if ( func == "AskUser" )
    {
	boolean has_next = param["has_next"]:false;

	Sound::installation = true;

	any sequence = WFM::CallFunction ( "sound", [] );

	// Fill return map
	ret =
	    $[ "workflow_sequence" : sequence
	    ];
    }
    // Return human readable titles for the proposal
    else if ( func == "Description" )
    {
	// Fill return map
	ret =
	    // section name in proposal dialog
	    $[ "rich_text_title" : _("Sound"),
		// section name in proposal - menu item
	       "menu_title"      : _("&Sound"),
	       "id"              : "sound_conf"
	    ];
    }
    else if ( func == "Write" )
    {
	Sound::Write ();
    }

    return ret;

/* EOF */
}
