/**
 * Module:      inst_user.ycp
 *
 * Authors:     Klaus Kaempf <kkaempf@suse.de>
 *              Stefan Hundhammer <sh@suse.de>
 *
 * Purpose:     Start user management module from within installation workflow
 *
 * $Id: inst_user.ycp 18232 2004-07-27 13:13:02Z jsuchome $
 */
{

    textdomain "users";

    import "Package";
    import "Label";
    import "Ldap";
    import "Users";

    any ret	= `back;

    // what to call after inst_auth dialog
    string client	= Users::AfterAuth();
    if (client != "users")
    {
        string package = sformat("yast2-%1-client", client);
	// name of client to call
        map call_client = $[
	    "samba": "samba-client",
	];
	if (Package::InstallAllMsg ([package],
            // popup label (%1 is package to install)
            sformat (_("Package %1 is not installed.
Install it now?
"), package)))
        {
            ret = (symbol) WFM::CallFunction (call_client [client]:client,
		WFM::Args ());
        }
        else
            return `back;

	if (ret == `next && client == "ldap" && Ldap::initial_defaults_used)
	{
	    // continue with users...
	    Users::SetAfterAuth ("users");
	    y2milestone("calling users module to enable creating LDAP user...");
	}
	else
	{
	    // ldap not used, or the client configuration is different than
	    // proposal from ldap server
	    return (symbol) ret;
	}
    }

    // else run the users module
    list start_params = [ "user_inst_start" ];

    y2debug("Starting user management module with parameters %1", start_params);
    ret = WFM::CallFunction ("users", start_params );
    y2debug("User management module returned %1", ret );

    if ( ret == nil )
    {
        y2warning( "Couldn't call 'users' module - is it installed?" );
        ret = `auto;
    }
    return (symbol) ret;
}
