ACC SHELL
/**
* File: include/network/provider/connection.ycp
* Package: Network configuration
* Summary: Connection configuration dialogs
* Authors: Michal Svec <msvec@suse.cz>
*
* $Id: connection.ycp 61770 2010-04-19 14:18:08Z mzugec $
*/
{
textdomain "network";
import "DSL";
import "IP";
import "ISDN";
import "Label";
import "NetworkInterfaces";
import "Modem";
import "Popup";
import "Provider";
import "SuSEFirewall4Network";
import "Wizard";
/**
* Connection dialog
* @return dialog result
*/
define any ConnectionDialog() {
ScreenName("provider-connection");
string type = Provider::Type;
/* PREPARE VARIABLES */
string Provider = Provider::Current["PROVIDER"]:"";
string startmode = "";
boolean demand = Provider::Current["DEMAND"]:"no" == "yes";
boolean stupidmode = Provider::Current["STUPIDMODE"]:"no" == "yes";
boolean modifydns = Provider::Current["MODIFYDNS"]:"yes" == "yes";
boolean autodns = Provider::Current["AUTODNS"]:"yes" == "yes";
// hide autoreconnect from UI (bnc#558788)
boolean autoreconnect = Provider::Current["AUTO_RECONNECT"]:"yes" == "yes";
string DNS1 = Provider::Current["DNS1"]:"";
string DNS2 = Provider::Current["DNS2"]:"";
string idletime = Provider::Current["IDLETIME"]:"900";
string device = nil;
string dtype = nil;
string did = nil;
if (type == "modem") {
dtype = Modem::type;
did = Modem::device;
startmode = Modem::startmode;
}
else if (type == "dsl") {
dtype = DSL::type;
did = DSL::device;
}
else if (type == "isdn") {
did = ISDN::device;
// FIXME: #18840
if(ISDN::type == "net")
dtype = "ippp";
else
dtype = ISDN::type;
}
else {
y2error("Unknown type: %1", type);
return nil;
}
y2debug("device %1", device);
// the device is not a property of the provider so it may happen
// that we do not have it. #146388
boolean FirewallChecked = false;
if (dtype != "")
{
device = did;
boolean adding = false;
if (type == "modem")
adding = Modem::Adding ();
else if (type == "dsl")
adding = DSL::Adding ();
if (adding) // #66478
{
FirewallChecked = true;
}
else
{
FirewallChecked = SuSEFirewall4Network::IsProtectedByFirewall (device);
}
}
y2debug("FirewallChecked=%1", FirewallChecked);
/* DIALOG TEXTS */
/* Connection dialog caption */
string caption = _("Connection Parameters");
/* Connection dialog help 1/9 */
string helptext = _("<p><b>Dial on Demand</b> means that the Internet
connection will be established automatically when data from the Internet is
requested. To use this feature, specify at least one <i>name server</i>. Use
this feature only if your Internet connection is inexpensive, because there are
programs that periodically request data from the Internet.</p>") +
/* Connection dialog help 2/9 */
_("<p>When <b>Modify DNS</b> is enabled, the <i>name server</i> will be
changed automatically when connected to the Internet.</p>") +
/* Connection dialog help 3/9 */
_("<p>If the provider does not transmit its domain name server (DNS)
after connecting, disable <b>Automatically Retrieve DNS</b> and
manually enter the DNS.</p>") +
/* Connection dialog help 4/9 */
//_("<p>If <b>Automatically Reconnect</b> is enabled, the connection will
//be reestablished automatically after failure.</p>
//") +
/* Connection dialog help 5/9 */
_("<p><b>Name Servers</b> are required to convert hostnames
(such as www.suse.com) to IP addresses (for example, 213.95.15.200). You only
need to specify the name servers if you enable dial on demand or
disable <b>DNS Modification</b> when connected.</p>
");
if (type == "modem")
helptext = helptext +
/* Connection dialog help 6/9 */
_("<p><b>Ignore Prompts</b> disables the detection of any prompts from the dial-up
server. If the connection build-up is slow or does not work at all, try this
option.</p>
");
helptext = helptext +
/* Connection dialog help 7/9 */
_("<p>Selecting <b>External Firewall Interface</b> activates the firewall
and sets this interface as external.
Choosing this option makes dial-up connections
to the Internet safe from external attacks.</p>") +
/* Connection dialog help 8/9 */
_("<p>The <b>Idle Time-Out</b> specifies the time after which an idle
connection will be shut down (0 means the connection will not time-out).</p>
");
// if(type == "isdn")
/* FIXME Connection dialog help 8/9 */
// helptext = helptext + _("<p><b>Connection details</b> help FIXME</p>") +
/* FIXME Connection dialog help 9/9 */
// _("<p><b>IP details</b> help FIXME</p>");
/* DIALOG CONTENTS */
list seconds = [ "0", "30", "60", "90", "120", "150", "180", "240", "300", "360", "480", "600" ];
if(!contains(seconds, idletime))
seconds = add(seconds, idletime);
seconds = maplist(string e, (list<string>) seconds, {
// translators: min - shortcut to "minutes" (fate#303429)
return `item(`id(sformat("%1", e)), sformat("%1 (%2 %3)", e, tofloat(e)/60, _("min")), e == idletime);
});
/* Checkbox label */
// this is an external interface protected by the firewall
term FirewallCheckbox = `Left(`CheckBox(`id(`Firewall), _("External Fire&wall Interface"), FirewallChecked));
if (device == nil || type == "isdn")
FirewallCheckbox = `VSpacing(0);
term StupidMode = `VSpacing(0.1);
if (type == "modem")
/* Checkbox label */
StupidMode = `Left(`CheckBox(`id(`stupidmode), _("I&gnore Prompts"), stupidmode));
term details = `VSpacing(0.1);
// FIXME if(type == "isdn")
if(false)
details = `HBox(
/* Push button label */
`PushButton(`id(`Details), _("&Connection Details")),
`HSpacing(0.5),
/* Push button label */
`PushButton(`id(`IPDetails), _("I&P Details"))
);
if(type != "isdn")
details = `HBox(
/* Push button label */
`PushButton(`id(`IPDetails), _("I&P Details"))
);
term STARTMODE=`Empty();
if (type=="modem")
STARTMODE=`Left(`ComboBox(`id(`startmode), _("How the interface should be set up"),
[ `item(`id("auto"), _("Automatically")),
`item(`id("manual"), _("Manually")),
`item(`id("off"), _("Off"))
]
));
term contents = `HBox(
`HSpacing(6),
`VBox(
`VSpacing(0.5),
`Left(`HBox(
/* Label */
`Label(_("Provider:")),
`HSpacing(0.5),
`Label(`opt(`outputField), Provider)
)),
`VSpacing(0.5),
`HBox(
`VBox(
STARTMODE,
/* Checkbox label */
`Left(`CheckBox(`id(`demand), `opt(`notify), _("Dial on D&emand"), demand)),
/* Checkbox label */
`Left(`CheckBox(`id(`modifydns), `opt(`notify), _("&Modify DNS When Connected"), modifydns)),
/* Checkbox label */
`Left(`CheckBox(`id(`autodns), `opt(`notify), _("&Automatically Retrieve DNS"), autodns))
/* Checkbox label */
// `Left(`CheckBox(`id(`autoreconnect), `opt(`notify), _("Automatically &Reconnect"), autoreconnect))
)
),
`VSpacing(1),
/* Frame label */
`Frame(`id(`nameservers), _("Name Servers"),
`HBox(
/* Text entry label */
`TextEntry(`id(`DNS1), _("F&irst"), DNS1),
`HSpacing(0.5),
/* Text entry label */
`TextEntry(`id(`DNS2), _("&Second"), DNS2)
)
),
`VSpacing(1),
StupidMode,
FirewallCheckbox,
`VSpacing(0.5),
/* Combo box label */
`Left(`ComboBox(`id(`idletime), `opt(`editable), _("I&dle Time-Out (seconds)"), seconds)),
`VSpacing(1),
details
),
`HSpacing(6)
);
/* DIALOG PREPARE */
Wizard::SetContentsButtons(caption, contents, helptext,
Label::BackButton(), Label::NextButton());
if (type=="modem") UI::ChangeWidget(`id(`startmode), `Value, startmode);
UI::ChangeWidget(`id(`nameservers), `Enabled, modifydns && (demand || !autodns));
/* MAIN CYCLE */
any ret = nil;
while(true) {
ret = UI::UserInput();
/* abort? */
if(ret == `abort || ret == `cancel) {
if(ReallyAbort()) break;
else continue;
}
else if(ret == `back) {
break;
}
else if(ret == `next || ret == `Details || ret == `IPDetails) {
/* check_* */
if(UI::QueryWidget(`id(`idletime), `Value) == "") {
/* Popup text */
Popup::Error(_("Set the idle time-out."));
UI::SetFocus(`id(`idletime));
continue;
}
if(modifydns && (demand || !autodns)) {
DNS1 = (string) UI::QueryWidget(`id(`DNS1), `Value);
DNS2 = (string) UI::QueryWidget(`id(`DNS2), `Value);
if(!(IP::Check4(DNS1))) {
Popup::Error(_("The primary name server is invalid."));
UI::SetFocus(`id(`DNS1));
continue;
}
if(size(DNS2) > 0 && !IP::Check4(DNS2)) {
Popup::Error(_("The secondary name server is invalid."));
UI::SetFocus(`id(`DNS2));
continue;
}
}
break;
}
else if(ret == `demand || ret == `modifydns || ret == `autodns) {
demand = (boolean) UI::QueryWidget(`id(`demand), `Value);
modifydns = (boolean) UI::QueryWidget(`id(`modifydns), `Value);
autodns = (boolean) UI::QueryWidget(`id(`autodns), `Value);
if (demand) {
UI::ChangeWidget(`id(`autodns), `Value, false);
}
UI::ChangeWidget(`id(`nameservers), `Enabled, modifydns && (demand || !autodns));
}
else {
y2error("unexpected retcode: %1", ret);
continue;
}
}
/* UPDATE VARIABLES */
if(ret == `next || ret == `Details || ret == `IPDetails) {
demand = (boolean) UI::QueryWidget(`id(`demand), `Value);
modifydns = (boolean) UI::QueryWidget(`id(`modifydns), `Value);
autodns = (boolean) UI::QueryWidget(`id(`autodns), `Value);
// autoreconnect = (boolean) UI::QueryWidget(`id(`autoreconnect), `Value);
/* update provider info */
Provider::Current = union(Provider::Current, $[
"DEMAND" : demand ? "yes" : "no",
"MODIFYDNS" : modifydns ? "yes" : "no",
"AUTODNS" : autodns ? "yes" : "no",
"AUTO_RECONNECT" : autoreconnect ? "yes" : "no",
"IDLETIME" : UI::QueryWidget(`id(`idletime), `Value),
"MODEMSUPPORTED" : type == "modem" ? "yes" : "no",
"ISDNSUPPORTED" : type == "isdn" ? "yes" : "no",
"DSLSUPPORTED" : type == "dsl" ? "yes" : "no"
]);
if (modifydns && (demand || !autodns))
Provider::Current = union(Provider::Current, $[
"DNS1" : UI::QueryWidget(`id(`DNS1), `Value),
"DNS2" : UI::QueryWidget(`id(`DNS2), `Value),
]);
/* update provider type-specific info */
if (type == "modem"){
Provider::Current = union(Provider::Current, $[
"STUPIDMODE" : (boolean) UI::QueryWidget(`id(`stupidmode), `Value) ? "yes" : "no"
]);
Modem::startmode = (string)UI::QueryWidget(`id(`startmode), `Value);
}
/* update firewall info */
if(UI::WidgetExists(`id(`Firewall))) {
/* Update /etc/sysconfig/firewall */
// if(FirewallChecked != UI::QueryWidget(`id(`Firewall), `Value)) {
FirewallChecked = (boolean) UI::QueryWidget(`id(`Firewall), `Value);
SuSEFirewall4Network::ProtectByFirewall (device, "EXT", FirewallChecked);
// }
}
}
return ret;
}
/**
* Connection details dialog
* @return dialog result
*/
define symbol ConnectionDetailsDialog() {
return `abort;
}
/* EOF */
}
ACC SHELL 2018