ACC SHELL
/**
* File:
* clients/mail.ycp
*
* Package:
* Configuration of mail
*
* Summary:
* Main file
*
* Authors:
* Peter Varkoly <varkoly@novell.com>
* Martin Vidner <mvidner@suse.cz>
*
* $Id: mail.ycp 61601 2010-04-07 12:52:02Z varkoly $
*
* Main file for mail configuration. Uses all other files.
*
*/
{
/***
* <h3>Configuration of the mail</h3>
*/
textdomain "mail";
import "Wizard";
import "Popup";
import "Label";
import "CommandLine";
/* The main () */
y2milestone ("Mail module started");
y2milestone ("----------------------------------------");
/* The maske to select the type of the configuration */
define string StartDialogHelp () ``{
return
// Translators: start dialog help, part 1 of 4
_("<P><B>Email Server Configuration</B><BR>") +
// Translators: start dialog help, part 2 of 4
_("<P>This module will configure and start Postfix and, if necessary, the Cyrus IMAP server.</P>")+
// Translators: start dialog help, part 3 of 4
_("<P><B>Warning:</B></P>
<P>Most home users can use the built-in
features of their e-mail application to send and
receive e-mail. They do not need this module.</P>
")+
// Translators: start dialog help, part 4 of 4
_("<P>You need Postfix only to store
the e-mail on your local system, or for some special cases.</P>
");
}
define string StartDialog (string type, boolean first ) ``{
y2milestone ("Mail configuration type %1", type);
Wizard::SetScreenShotName ("mail-0-start");
string caption = _("E-Mail Server Configuration");
term tskip_ask = `Left(`CheckBox(`id(`skip_ask), _("Skip this page in the future")));
string status = _("Mail server is not configured.")+"\n"+
_("Select configuration type according your personal needs")+"\n"+
_("If you want to use sendmail as your MTA you have to use Standard configuration.")+
_("The Advanced configuration use LDAP as backend and will configure your system as LDAP-Client and setup an LDAP-Server if necessary.");
if( first )
{
tskip_ask = `VSpacing(1);
}
else
{
if( type == "standard" )
{
status = _("The running mail server configuration is based on the \"Standard\" type.")+ "\n"+
_("It is possible to change to \"Advanced\" settings. This will overwrite all existing settings.");
}
else if( type == "advanced" )
{
status = _("The running mail server configuration is based on the \"Advanced\" type.")+"\n"+
_("It is possible to change to \"Standard\" settings. This will overwrite all existing settings.");
}
}
term contents =
`Frame(
"",
`VBox(
`Left(`Label(status)),
`RadioButtonGroup( `id( `conf_type ),
`VBox(
`VSpacing(1),
`Left(`RadioButton(`id("standard"),_("Standard"), type == "standard" )),
`VSpacing(1),
`Left(`RadioButton(`id("advanced"),_("Advanced"), type == "advanced" )),
`VSpacing(1)
)
),
tskip_ask,
`VSpacing(1)
)
);
Wizard::CreateDialog();
Wizard::SetContentsButtons (caption, contents, StartDialogHelp(), Label::BackButton (), Label::NextButton ());
any ret = nil;
string sret = nil;
while (true)
{
ret = UI::UserInput ();
if (ret == `cancel)
{
ret = `abort;
}
if (ret == `back || (ret == `abort ))
{
break;
}
if (ret == `next )
{
if( ! first )
{
if( (boolean) UI::QueryWidget (`id (`skip_ask), `Value) )
{
SCR::Write (.sysconfig.mail.SKIP_ASK, "yes");
}
}
else
{
SCR::Write (.sysconfig.mail.SKIP_ASK, "no");
}
sret = (string) UI::QueryWidget (`id (`conf_type), `CurrentButton);
if( sret == nil )
{
Popup::Error(_("You have to select a configuration type"));
continue;
}
y2milestone ("Mail configuration type %1", sret);
break;
}
}
UI::CloseDialog();
return sret;
}
/****************/
/* MAIN ROUTINE */
/****************/
define any Main() ``{
/* parse arguments */
list args = WFM::Args ();
/* we collect some informations from the system */
any ret = nil;
string skip_ask = "no";
string conf_type = "undef";
skip_ask = (string) SCR::Read (.sysconfig.mail.SKIP_ASK);
conf_type = (string) SCR::Read (.sysconfig.mail.CONFIG_TYPE);
boolean first_start = false;
map local_recipient_maps = (map) SCR::Read (.mail.ldaptable, "local_recipient_maps");
if( conf_type != "advanced" && conf_type != "standard" )
{ // First start of mail modul or update from < 10.3
if( local_recipient_maps != nil )
{ // Postfix configured using LDAP
conf_type = "advanced";
}
else
{
conf_type = "standard";
}
first_start = true;
}
if( skip_ask == "no" || skip_ask == nil )
{
string old_conf = conf_type;
conf_type = StartDialog(conf_type,first_start);
if( conf_type == nil )
{
y2milestone("no mail server configuration type");
return ret;
}
if( old_conf != conf_type )
{
first_start = true;
}
}
if( conf_type == "advanced" )
{
if( first_start )
{
args[size(args)] = "setup";
}
ret = WFM::CallFunction("mail-advanced",args);
}
else
{
ret = WFM::CallFunction("mail-standard",args);
}
y2milestone ("Mail module %1 returned %2", conf_type, ret);
if( ret != nil && ret != `cancel && ret != `abort )
{
SCR::Write (.sysconfig.mail.CONFIG_TYPE, conf_type);
}
}
define boolean Setup (map<string, string> options) ``{
Main();
return true;
}
/**
* Command line definition
*/
map cmdline = $[
/* Commandline help title */
// configuration of hosts
"help" : _("Mail Server Configuration"),
"id" : "mail",
"guihandler": Main,
// "initialize": Host::Read,
// "finish" : Host::Write, // FIXME
"actions" : $[
"setup" : $[
/* Commandline command help */
"help" : _("Set Up the Mail Server Configuration"),
"handler" : Setup,
],
],
];
any ret = CommandLine::Run(cmdline);
y2debug("ret=%1", ret);
/* Finish */
y2milestone ("Mail module finished");
return ret;
}
ACC SHELL 2018