ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/software_proposal.ycp

/**
 * Module:		software_proposal.ycp
 *
 * Author:		Klaus Kaempf <kkaempf@suse.de>
 *
 * Purpose:		Proposal function dispatcher - software.
 *
 *			See also file proposal-API.txt for details.
 *
 * $Id: software_proposal.ycp 44508 2008-02-15 13:01:24Z jsrain $
 *
 */
{
    textdomain "packager";

    import "Packages";
    import "Language";
    import "Installation";

    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;

	boolean reinit = false;
	boolean partition_changed = false;

	if (Installation::dirinstall_installing_into_dir)
	{
	    // check the target directory in dirinstall mode
	    if ( Packages::timestamp != Installation::dirinstall_target_time )
	    {
		partition_changed = true;
	    }
	    // save information about target change time in module Packages
	    Packages::timestamp = Installation::dirinstall_target_time;
	}
	else
	{
	    integer storage_timestamp = (integer)WFM::call("wrapper_storage", ["GetTargetChangeTime"]);

	    // check the partitioning in installation
	    if ( Packages::timestamp != storage_timestamp )
	    {
		// don't set flag partition_changed if it's the first "change"
		if ( Packages::timestamp != 0 )
		{
		    partition_changed = true;
		}
	    }
	    // save information about target change time in module Packages
	    Packages::timestamp = storage_timestamp;
	}

	if (Pkg::GetPackageLocale () != Language::language)
	{
	    language_changed = true;
	    Pkg::SetPackageLocale (Language::language);
	}
	if (! contains (Pkg::GetAdditionalLocales (), Language::language))
	{
// FIXME this is temporary fix
//	    language_changed = true;
	    Pkg::SetAdditionalLocales (
		add (Pkg::GetAdditionalLocales (), Language::language));
	}

	if ( language_changed || partition_changed )
	{
	    reinit = true;
	}
	y2milestone("package proposal: force reset: %1, reinit: %2, language changed: %3",  force_reset, reinit, language_changed );
	ret = Packages::Proposal( force_reset,		// user decision: reset to default
				  reinit,		// reinitialize due to language or partition change
				  false );		// simple version

	if ( language_changed && !force_reset)
	{
	    // if the  language has changed the software proposal is reset to the default settings
	    if (! haskey (ret, "warning"))
	    {
		// the language_changed flag has NOT been set by the NLD frame
		ret = add( ret, "warning", _("The software proposal is reset to the default values.") );
	    }
	}
        if (Packages::solve_errors > 0)
        {
             // the proposal for the packages requires manual intervention
            ret = union (ret, $[
                        /* warning text */
                     "warning" : _("Cannot solve dependencies automatically. Manual intervention is required."),
                     "warning_level" : `blocker ]);
        }
    }
    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 );

	any chosen_id = param["chosen_id"]:nil;
	if (chosen_id == "mediacheck")
	{
	    symbol result = (symbol)WFM::CallFunction("checkmedia", WFM::Args());
	    ret = $[ "workflow_sequence" : result ];
	}
	else
	{
	    symbol result = `again;
	    string client_to_call = "inst_sw_select";

	    while ( result == `again )
	    {
		result = (symbol) WFM::CallFunction (client_to_call, [true, true]);
	    }

	    // Fill return map

	    ret = $[ "workflow_sequence" : result ];
	}
    }
    else if ( func == "Description" )
    {
	// disable proposal if doing image-only installation
	if (Installation::image_only)
	    return nil;
	// Fill return map.
	//
	// Static values do just nicely here, no need to call a function.

	ret =
	    $[
	      // this is a heading
	      "rich_text_title"	:	_("Software"),
	      // this is a menu entry
	      "menu_title"	:	_("&Software"),
	      "id"		:	"software_stuff"
	    ];
    }

    return ret;
}

ACC SHELL 2018