/**
 * File:
 *   TftpServer_auto.ycp
 *
 * Package:
 *   Configuration of TFTPSERVER
 *
 * Summary:
 *   Client for autoinstallation
 *
 * Authors:
 *   Martin Vidner <mvidner@suse.cz>
 *
 * $Id: tftp-server_auto.ycp 20634 2005-01-03 15:15:17Z 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 TFTPSERVER settings
 * @return map edited settings or an empty map if canceled
 * @example map mm = $[ "FAIL_DELAY" : "77" ];
 * @example map ret = WFM::CallModule ("tftp-server_auto", [ mm ]);
 */

{
textdomain "tftp-server";

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

import "TftpServer";
include "tftp-server/wizards.ycp";

any ret = nil;
string func = "";
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), map))
	param = (map) WFM::Args(1);
}
y2debug("func=%1", func);
y2debug("param=%1", param);

/* Create a summary*/
if(func == "Summary") {
    ret = TftpServer::Summary();
}
/* Reset configuration */
else if (func == "Reset") {
    TftpServer::Import($[]);
    ret = $[];
}
/* Change configuration (run AutoSequence) */
else if (func == "Change") {
    ret = TftpServerAutoSequence();
}
/* Import configuration */
else if (func == "Import") {
    ret = TftpServer::Import(param);
}
/* Return package list */
else if (func == "Packages") {
    ret = TftpServer::AutoPackages();
}
/* Return actual state */
else if (func == "Export") {
    ret = TftpServer::Export();
}
/* Read current state */
else if (func == "Read") {
    import "Progress";
    boolean progress_orig = Progress::set (false);
    ret = TftpServer::Read();
    Progress::set (progress_orig);
}
/* Write givven settings */
else if (func == "Write") {
    import "Progress";
    boolean progress_orig = Progress::set (false);
    ret = TftpServer::Write();
    Progress::set (progress_orig);
}
else if (func == "SetModified") {
    ret = TftpServer::SetModified ();
}
else if (func == "GetModified") {
    ret = TftpServer::GetModified ();
}
/* Unknown function */
else {
    y2error("Unknown function: %1", func);
    ret = false;
}

return ret;

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

}
