/**
 * File:
 *   nfs_auto.ycp
 *
 * Package:
 *   Configuration of NFS client
 *
 * Summary:
 *   Client for autoinstallation
 *
 * Authors:
 *   Martin Vidner <mvidner@suse.cz>
 *
 * $Id: nfs_auto.ycp 20632 2005-01-03 12:54:47Z mvidner $
 *
 * This is a client for autoinstallation. It takes its arguments,
 * goes through the configuration and return the setting.
 * Does not do any changes to the configuration.
 */

/**
 * @param first a map of mail settings
 * @return map edited settings or empty map if canceled
 * @example map mm = $[ "FAIL_DELAY" : "77" ];
 * @example map ret = WFM::CallModule ("mail_auto", [ mm ]);
 */

{
textdomain "nfs";

y2milestone("----------------------------------------");
y2milestone("Nfs auto started");

import "Nfs";
import "Wizard";
include "nfs/ui.ycp";

any ret = nil;
string func = "";
list<map> param = [];

/* Check arguments */
if(size(WFM::Args()) > 0 && is(WFM::Args(0), string)) {
    func = (string) WFM::Args(0);
    if(size(WFM::Args()) > 1 && is(WFM::Args(1), list))
	param = (list<map>) WFM::Args(1);
}
y2debug("func=%1", func);
y2debug("param=%1", param);

/* Create a  summary*/
if(func == "Import") {
    ret = (boolean) Nfs::Import(param);
}
/* Create a  summary*/
else if(func == "Summary") {
    ret = (string) Nfs::Summary();
}
/* Reset configuration */
else if (func == "Reset") {
    Nfs::Import([]);
    ret = [];
}
/* Change configuration (run AutoSequence) */
else if (func == "Change") {
    Wizard::CreateDialog ();
    Wizard::SetDesktopIcon("nfs");
    ret = (symbol) FstabDialog ();
    UI::CloseDialog ();
}
else if (func == "GetModified") {
    ret =  Nfs::GetModified();
}
else if (func == "SetModified") {
    Nfs::SetModified();
}
/* Return actual state */
else if (func == "Packages") {
    ret = (map) Nfs::AutoPackages();
}
/* Return actual state */
else if (func == "Export") {
    ret = (list) Nfs::Export();
}
else if (func == "Read") {
    ret = (boolean)  Nfs::Read();
}
/* Write givven settings */
else if (func == "Write") {
    import "Progress";
    boolean progress_orig = Progress::set (false);
    ret = (boolean) Nfs::WriteOnly();
    Progress::set (progress_orig);
}
/* Unknown function */
else {
    y2error("Unknown function: %1", func);
    ret = false;
}

y2debug("ret=%1", ret);
y2milestone("Nfs auto finished");
y2milestone("----------------------------------------");

return ret;

/* EOF */
}

