-
Notifications
You must be signed in to change notification settings - Fork 34
/
dialogs.ycp
292 lines (256 loc) · 8.98 KB
/
dialogs.ycp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/**
* File: include/network/dsl/dialogs.ycp
* Package: Network configuration
* Summary: Configuration dialogs for DSL
* Authors: Michal Svec <msvec@suse.cz>
*
*/
{
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() {
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 */
}