ACC SHELL

Path : /proc/self/root/usr/share/YaST2/modules/
File Upload :
Current File : //proc/self/root/usr/share/YaST2/modules/Irda.ycp

/**
 * File:	modules/Irda.ycp
 * Package:	Configuration of irda
 * Summary:	Irda settings, input and output functions
 * Authors:	Jiri Suchomel <jsuchome@suse.cz>
 *
 * $Id: Irda.ycp 52287 2008-10-16 11:07:14Z jsuchome $
 *
 * Representation of the IrDA configuration.
 * Input and output routines.
 */

{

module "Irda";
textdomain "irda";

import "FileUtils";
import "Progress";
import "Service";

/**
 * Data was modified?
 */
global boolean modified = false;

/**
 * Should irda be started?
 */
global boolean start	= false;

/**
 * serial port used for irda
 */
global string port	= "";

/**
 * Maximum baud rate for the IrDA serial port
 */
global string max_baud_rate	= "0";

/**
 * Read irda settings from /etc/sysconfig/irda
 * @return true when file exists
 */
global define boolean ReadSysconfig () {


    if (FileUtils::Exists ("/etc/sysconfig/irda"))
    {
	port = (string) SCR::Read (.sysconfig.irda.IRDA_PORT);
	if (port == nil)
	    port = "";

	max_baud_rate = (string) SCR::Read (.sysconfig.irda.IRDA_MAX_BAUD_RATE);
	if (max_baud_rate == nil)
	    max_baud_rate = "0";
	return true;
    }
    return false;
}

/**
 * Read all irda settings
 * @return true on success
 */
global define boolean Read () {

    ReadSysconfig ();

    start = (Service::Status ("irda") == 0);

    return true;
}

/**
 * Write all irda settings
 * @return true on success
 */
global define boolean Write () {

    if (!modified)
	return true;

    /* Irda read dialog caption */
    string caption	= _("Saving IrDA Configuration");
    integer steps	= 2;

    Progress::New (caption, " ", steps, [
	    /* Progress stage 1/2 */
	    _("Write the settings"),
	    /* Progress stage 2/2 */
	    _("Restart the service")
	], [
	    /* Progress step 1/2 */
	    _("Writing the settings..."),
	    /* Progress step 2/2 */
	    _("Restarting service..."),
	    /* Progress finished */
	    _("Finished")
	],
	""
    );

    Progress::NextStage();

    if (port != "")
    {
	SCR::Write (.sysconfig.irda.IRDA_PORT, port);
    }
    if (max_baud_rate != nil)
    {
	SCR::Write (.sysconfig.irda.IRDA_MAX_BAUD_RATE, max_baud_rate);
    }
    SCR::Write (.sysconfig.irda, nil);

    Progress::NextStage ();

    Service::Stop ("irda");
    if (start)
    {
	Service::Start ("irda");
	Service::Enable ("irda");
    }
    else
    {
	Service::Disable ("irda");
    }

    Progress::NextStage();

    return true;
}

/* EOF */
}

ACC SHELL 2018