ACC SHELL
/**
* File: include/network/dsl/dialogs.ycp
* Package: Network configuration
* Summary: Configuration dialogs for DSL
* Authors: Michal Svec <msvec@suse.cz>
*
* $Id: dialogs.ycp 46777 2008-04-17 09:11:27Z kmachalkova $
*/
{
textdomain "network";
import "Call";
import "CWM";
import "DSL";
import "IP";
import "Label";
import "Lan";
import "NetworkInterfaces";
import "Popup";
import "SuSEFirewall4Network";
import "Wizard";
import "LanItems";
import "Hostname";
include "network/runtime.ycp";
include "network/routines.ycp";
include "network/widgets.ycp";
include "network/installation/dialogs.ycp";
/**
* DSL device dialog
* @return dialog result
*/
define any DSLDialog() {
ScreenName("dsl-dialog");
widget_descr["STARTMODE"] = MakeStartmode (
["auto", "hotplug", "manual", "off", ]);
/* DSL dialog caption */
string caption = _("DSL Configuration");
/* DSL dialog help 1/8 */
string helptext = _("<p>Here, set the most important settings
for the DSL connection.</p>
") +
/* DSL dialog help 2/8 */
_("<p>First, choose your <b>PPP mode</b>. This is either
<i>PPP over Ethernet</i> (PPPoE), <i>PPP over ATM</i> (PPPoATM),
<i>CAPI for ADSL</i> or <i>Point to Point Tunneling Protocol</i> (PPTP).
Use <i>PPP over Ethernet</i> if your DSL modem is connected via ethernet to your computer.
Use <i>Point to Point Tunneling Protocol</i> if you want to connect to a VPN server.
If you are not sure which mode to use, ask your provider. </p>") +
/* DSL dialog help 3/8 */
_("<p>If you are using <i>PPP over Ethernet</i>, first configure your
ethernet card.</p>") +
/* DSL dialog help 4/8 */
_("<p>The <b>PPP Mode-Dependent Settings</b> are settings required to set up
your DSL connection. <b>VPI/VCI</b> makes sense only for <i>PPP over ATM</i>
connections, <b>Ethernet Card</b> is needed for <i>PPP over Ethernet</i>
connections.</p>
") +
/* DSL dialog help 5/8 */
_("<p><b>For PPPoATM, enter your VPI/VCI pair, for example, <i>0.38</i>
for British Telecom. If unsure, ask your provider.</p>") +
/* DSL dialog help 6/8 */
_("<p>For PPPoE, enter the device of the ethernet card to which your DSL
modem is connected. If you did not set up your ethernet card yet, do
so by pressing <b>Configure Network Cards</b>.</p>") +
/* DSL dialog help 7/8 */
_("<p>For PPTP, enter the server name or IP address.</p>") +
widget_descr["STARTMODE", "help"]:"" +
/* DSL dialog help 8/8 */
_("<p>Activation during boot may
be appropriate for dial-on-demand connections.</p>") +
widget_descr["USERCONTROL", "help"]:"";
string pppmode = DSL::pppmode;
if (pppmode == nil || pppmode == "")
pppmode = "pppoe";
list pppmodes = [
/* ComboBox item */
`item(`id("pppoe"), _("PPP over Ethernet"), pppmode == "pppoe"),
/* ComboBox item */
`item(`id("pppoatm"), _("PPP over ATM"), pppmode == "pppoatm"),
/* ComboBox item */
`item(`id("capi-adsl"), _("CAPI for ADSL"), pppmode == "capi-adsl"),
/* ComboBox item */
`item(`id("pptp"), _("Point to Point Tunneling Protocol"), pppmode == "pptp"),
];
/* ComboBox label */
term pppwidget = `Left(`ComboBox(`id(`pppmode), `opt(`hstretch,`notify), _("PPP &Mode"), pppmodes));
string vpivci = DSL::vpivci;
string startmode = DSL::startmode;
boolean usercontrol = DSL::usercontrol;
string interface = DSL::interface;
string modemip = DSL::modemip;
list ifaces = [];
/**
*/
// define void UpdateInterfaces() {
list<string> items = getNetDeviceItems();
if(size(items)>0 && interface=="") interface=items[0]:"";
/* FIXME Why is not the current interface added? */
if(false && /*interface != "" && */!contains(ifaces, interface)) ifaces = add(ifaces, interface);
//}
/* FIXME: #suse27137 */
// UpdateInterfaces();
if(size(items) < 1) {
NetworkInterfaces::Push();
if(Lan::Propose()) {
// UpdateInterfaces();
// list<term (term (string), string, boolean)>
string i = ifaces[0, 0, 0]:"";
y2milestone("i=%1", i);
Lan::Edit(i);
LanItems::bootproto = "";
LanItems::ipaddr = "";
LanItems::Commit();
}
NetworkInterfaces::Pop();
}
list<map> widgets = CWM::CreateWidgets (
["USERCONTROL", "STARTMODE",],
widget_descr);
// list<string> items = NetworkInterfaces::List("");
/*
NetworkInterfaces::Read();
map <string, string> device_descr = GetDeviceDescription(items[0]:"");
y2internal("device_descr %1", device_descr);
string connection_text = _("%1 - %2 (%3)");
*/
/* DSL dialog contents */
term contents = `HBox(
`HSpacing(6),
/* Frame label */
`Frame(_("DSL Connection Settings"), `HBox(`HSpacing(2), `VBox(
`VSpacing(1),
pppwidget,
`VSpacing(1),
/* Frame label */
`Frame(_("PPP Mode-Dependent Settings"), `HBox(`HSpacing(2), `VBox(
`VSpacing(0.2),
/* TextEntry label */
`TextEntry(`id(`vpivci), _("&VPI/VCI"), vpivci),
`VSpacing(0.2),
`Frame(_("&Ethernet Card"),
`HBox(
/* RadioButton label */
// `Left(`ReplacePoint(`id(`rp), `Label(`id(`yes), sformat(connection_text, device_descr["name"]:"", device_descr["type"]:"", device_descr["ipaddr"]:_("No IP address assigned"))))),
// push button label
getDeviceContens(interface)
)),
`PushButton(`id(`lan), _("&Configure Network Cards")),
`VSpacing(0.2),
/* TextEntry label */
`TextEntry(`id(`modemip), _("&Server Name or IP Address"), modemip)
), `HSpacing(2))),
`VSpacing(1),
// STARTMODE
`Left (widgets[1, "widget"]:`Empty ()),
`VSpacing (0.5),
// USERCONTROL
// 0 is index to CreateWidgets... ugly
`Left (widgets[0, "widget"]:`Empty ()),
`VSpacing(1)
), `HSpacing(2))),
`HSpacing(6)
);
Wizard::SetContentsButtons(caption, contents, helptext,
Label::BackButton(), Label::NextButton());
UI::ChangeWidget (`id ("USERCONTROL"), `Value, usercontrol);
UI::ChangeWidget (`id ("STARTMODE"), `Value, startmode);
UI::ChangeWidget(`id(`vpivci), `Enabled, pppmode == "pppoatm");
enableDevices(pppmode == "pppoe" || pppmode == "pptp");
UI::ChangeWidget(`id(`lan), `Enabled, pppmode == "pppoe" || pppmode == "pptp");
UI::ChangeWidget(`id(`modemip), `Enabled, pppmode == "pptp");
any ret = nil;
while(true) {
ret = UI::UserInput();
if(ret == `abort || ret == `cancel) {
if(ReallyAbort()) break;
else continue;
}
else if(ret == `back) {
break;
}
else if(ret == `next) {
/* check_* */
pppmode = (string) UI::QueryWidget(`id(`pppmode), `Value);
// interface = (string) UI::QueryWidget(`id(`interface), `Value);
vpivci = (string) UI::QueryWidget(`id(`vpivci), `Value);
modemip = (string) UI::QueryWidget(`id(`modemip), `Value);
if(pppmode == "pppoatm" && vpivci == "") {
/* Popup text */
Popup::Error(_("Enter the VPI/VCI."));
UI::SetFocus(`id(`vpivci));
continue;
}
if((pppmode == "pppoe" || pppmode == "pptp") && interface == "") {
/* Popup text */
Popup::Error(_("At least one ethernet interface must be configured."));
UI::SetFocus(`id(`lan));
continue;
}
if(pppmode == "pptp" && !IP::Check4(modemip) && !Hostname::CheckDomain(modemip)) {
/* Popup text */
Popup::Error(_("Server IP address or domain name is invalid."));
UI::SetFocus(`id(`modemip));
continue;
}
break;
}
else if(ret == `pppmode) {
pppmode = (string) UI::QueryWidget(`id(`pppmode), `Value);
UI::ChangeWidget(`id(`vpivci), `Enabled, pppmode == "pppoatm");
enableDevices(pppmode == "pppoe"|| pppmode == "pptp");
// UI::ChangeWidget(`id(`interface), `Enabled, pppmode == "pppoe" || pppmode == "pptp");
UI::ChangeWidget(`id(`lan), `Enabled, pppmode == "pppoe" || pppmode == "pptp");
UI::ChangeWidget(`id(`modemip), `Enabled, pppmode == "pptp");
continue;
}
else if(ret == `lan) {
// WFM::CallFunction("lan_proposal", ["AskUser"]);
NetworkInterfaces::Push();
Call::Function("lan_proposal", ["AskUser"]);
NetworkInterfaces::Pop();
items = getNetDeviceItems();
refreshDevice(interface);
// interface = (string) UI::QueryWidget(`id(`interface), `Value);
// UpdateInterfaces();
// UI::ReplaceWidget(`id(`rp), `ComboBox(`id(`interface), _("&Ethernet Card"), ifaces));
continue;
}
else if (ret == `net_expert) interface = handleDevice (items, interface);
else {
y2error("Unexpected return code: %1", ret);
continue;
}
}
if(ret == `next) {
pppmode = (string) UI::QueryWidget(`id(`pppmode), `Value);
DSL::pppmode = pppmode;
if(pppmode == "pppoe" || pppmode == "pptp")
{
DSL::interface = interface;//(string) UI::QueryWidget(`id(`interface), `Value);
// If firewall is active and interface in no zone, nothing
// gets through (#47309) so add it to the external zone
if (SuSEFirewall4Network::IsOn ())
{
SuSEFirewall4Network::ProtectByFirewall (DSL::interface,
"EXT", true);
}
}
if(pppmode == "pppoatm")
DSL::vpivci = (string) UI::QueryWidget(`id(`vpivci), `Value);
if(pppmode == "pptp")
DSL::modemip = (string) UI::QueryWidget(`id(`modemip), `Value);
DSL::startmode = (string) UI::QueryWidget(`id("STARTMODE"), `Value);
DSL::usercontrol = (boolean) UI::QueryWidget (`id ("USERCONTROL"), `Value);
}
return ret;
}
/* EOF */
}
ACC SHELL 2018