ACC SHELL

Path : /usr/share/YaST2/include/mail/
File Upload :
Current File : //usr/share/YaST2/include/mail/mail-server_complex.ycp

/**
 * File:	include/mail/complex.ycp
 * Package:	Configuration of mail-server
 * Summary:	Dialogs definitions
 * Authors:	Peter Varkoly <varkoly@suse.de>
 *
 * $Id: complex.ycp 19955 2004-10-26 12:28:16Z varkoly $
 */

{

textdomain "mail";

import "Label";
import "Popup";
import "Wizard";
import "Wizard_hw";
import "MailServer";
import "Progress";

include "mail/mail-server_helps.ycp";
include "mail/mail-server_dialogs.ycp";

/**
 * Return a modification status
 * @return true if data was modified
 */
boolean Modified() {
    return MailServer::Modified();
}

boolean PollAbort() {
    return UI::PollInput() == `abort;
}

/**
 * Read settings dialog
 * @return `abort if aborted and `next otherwise
 */
symbol SetupDialog() {
    Wizard::RestoreHelp(HELPS["setup"]:"");
    string caption = _("Set up the mail server");
    integer steps =  3;
    integer sl    =  3;

    y2milestone("----- Start MailServer::Setup -----");

    // We do not set help text here, because it was set outside
    Progress::New( caption, "", steps, [
            /* Progress stage 0/3 */
            _("Read needed packages"),
            /* Progress stage 1/3 */
            _("Read LDAP settings"),
            /* Progress stage 2/3 */
            _("Choose LDAP and CA settings"),
            /* Progress stage 3/3 */
            _("Configure LDAP server and CA management")
        ], [
            /* Progress stage 0/7 */
            _("Reading packages..."),
            /* Progress stage 1/3 */
            _("Reading LDAP settings..."),
            /* Progress stage 2/3 */
            _("Choosing LDAP and CA settings..."),
            /* Progress stage 3/3 */
            _("Configuring LDAP server and CA management..."),
            /* Progress finished */
            _("Finished")
        ]
        , ""
    );

    // read  packages
    Progress::NextStage();
    if( ! MailServer::CheckPackages() )
    {
        return `abort;
    }
    sleep(sl);
    // read  packages
    Progress::NextStage();
    if( CheckLDAPDialog() != `ok )
    {
        return `abort;
    }
    sleep(sl);
    return `next;
}

/**
 * Read settings dialog
 * @return `abort if aborted and `next otherwise
 */
symbol ReadDialog()
{
    /*
       after merging yast2-mail and yast2-mail-server we have to be
       carefull not to corrupt the configuration of the other modul
    */
    if( !MailServer::setup && SCR::Read (.sysconfig.mail.MAIL_CREATE_CONFIG)== "yes" )
    {
	if(
	    ! Popup::AnyQuestionRichText(
		Label::WarningMsg(),
		_("You have configured your MTA without LDAP support.<br>") +
		_("This modul will configure your MTA with LDAP support.<br>")  +
		_("This will corrupt your current configuration."),
		80, 10,
		Label::ContinueButton(),
		Label::CancelButton(),
		`focus_no
	     )
	  )
	  {
	     return `abort;
	  }
    }

    Wizard::RestoreHelp(HELPS["read"]:"");
    boolean ret = MailServer::Read();
    return ret ? `next : `abort;
}

/**
 * Write settings dialog
 * @return `abort if aborted and `next otherwise
 */
symbol WriteDialog()
{
    Wizard::CreateDialog ();
    Wizard::SetDesktopIcon("mail");
    Wizard::RestoreHelp(HELPS["write"]:"");
    boolean ret = MailServer::Write();
    return ret ? `next : `abort;
}

/**
 * Summary dialog
 * @return dialog result
 */
any SummaryDialog() {

    /* MailServer summary dialog caption */
    string caption = _("Mail Server Configuration");

    /* FIXME */
    list summary = MailServer::Summary();
    list unconfigured = summary[1]:[];
    string configured = summary[0]:"";

    /* Frame label */
    term contents = Wizard_hw::DetectedContent(_("Mail Server to Configure"),
	    unconfigured, false, configured);

    Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"",
	    Label::BackButton(), Label::FinishButton());

    any ret = nil;
    while(true) {

	ret = UI::UserInput();

	/* abort? */
	if(ret == `abort || ret == `cancel || ret == `back) {
	    if(ReallyAbort()) break;
	    else continue;
	}
        /* overview dialog */
        else if(ret == `edit_button) {
            ret = `overview;
            break;
        }
        /* configure the selected device */
        else if(ret == `configure_button) {
	    // TODO FIXME: check for change of the configuration
            any selected = UI::QueryWidget(`id(`detected_selbox), `CurrentItem);
            if(selected == `other) {
                ret = `other;
            }
            else {
                ret = `configure;
            }
            break;
        }
        else if(ret == `next) {
            break;
        }
        else {
            y2error("unexpected retcode: %1", ret);
            continue;
        }
    }

    return ret;
}

/**
 * Overview dialog
 * @return dialog result
 */
any OverviewDialog() {

    /* MailServer overview dialog caption */
    string caption = _("Mail Server Overview");

    list overview = MailServer::Overview();

    /* FIXME table header */
    term contents = Wizard_hw::ConfiguredContent(
	/* Table header */
	`header(_("Number"), _("Mail Server")),
	overview, nil, nil, nil, nil );

    contents = Wizard_hw::SpacingAround(contents, 1.5, 1.5, 1.0, 1.0);

    Wizard::SetContentsButtons(caption, contents, HELPS["overview"]:"",
	    Label::BackButton(), Label::FinishButton());

    any ret = nil;
    while(true) {

	ret = UI::UserInput();

	/* abort? */
	if(ret == `abort || ret == `cancel) {
	    if(ReallyAbort()) break;
	    else continue;
	}
        /* add */
        else if(ret == `add_button) {
	    /* FIXME */
            ret = `add;
            break;
        }
        /* edit */
        else if(ret == `edit_button) {
	    /* FIXME */
            ret = `edit;
            break;
        }
        /* delete */
        else if(ret == `delete_button) {
	    /* FIXME */
            continue;
        }
        else if(ret == `next || ret == `back) {
            break;
        }
        else {
            y2error("unexpected retcode: %1", ret);
            continue;
        }
    }

    return ret;
}

/* EOF */
}

ACC SHELL 2018