[yast-commit] r38227 - in /trunk/network: VERSION package/yast2-network.changes src/dsl/dialogs.ycp src/installation/dialogs.ycp src/modules/Lan.ycp src/routines/widgets.ycp
Author: mzugec Date: Thu May 31 17:46:34 2007 New Revision: 38227 URL: http://svn.opensuse.org/viewcvs/yast?rev=38227&view=rev Log: merge code for select interfaces in InternetTest and Dsl (#117426) Modified: trunk/network/VERSION trunk/network/package/yast2-network.changes trunk/network/src/dsl/dialogs.ycp trunk/network/src/installation/dialogs.ycp trunk/network/src/modules/Lan.ycp trunk/network/src/routines/widgets.ycp Modified: trunk/network/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/VERSION?rev=38227&r1=... ============================================================================== --- trunk/network/VERSION (original) +++ trunk/network/VERSION Thu May 31 17:46:34 2007 @@ -1 +1 @@ -2.15.37 +2.15.38 Modified: trunk/network/package/yast2-network.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/package/yast2-network.cha... ============================================================================== --- trunk/network/package/yast2-network.changes (original) +++ trunk/network/package/yast2-network.changes Thu May 31 17:46:34 2007 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Thu May 31 17:44:21 CEST 2007 - mzugec@suse.cz + +- merge code for select interfaces in InternetTest and Dsl (#117426) +- 2.15.38 + +------------------------------------------------------------------- Wed May 30 11:34:16 CEST 2007 - mzugec@suse.cz - fixed spec requirements Modified: trunk/network/src/dsl/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/dsl/dialogs.ycp?rev=3... ============================================================================== --- trunk/network/src/dsl/dialogs.ycp (original) +++ trunk/network/src/dsl/dialogs.ycp Thu May 31 17:46:34 2007 @@ -106,33 +106,21 @@ /** */ - define void UpdateInterfaces() { - ifaces = NetworkDevices::List("eth"); - y2debug("ifaces=%1", ifaces); - ifaces = union(ifaces, NetworkDevices::List("eth-pcmcia")); - y2debug("ifaces=%1", ifaces); - ifaces = union(ifaces, NetworkDevices::List("eth-usb")); - ifaces = union(ifaces, NetworkDevices::List("wlan")); // #186102 - y2debug("ifaces=%1", ifaces); - + // define void UpdateInterfaces() { +list<string> items = getNetDeviceItems(); +if(size(items)>0 && interface=="") interface=items[0]:""; +y2internal("items %1", items); /* FIXME Why is not the current interface added? */ - if(false && /*interface != "" && */!contains(ifaces, interface)) - ifaces = add(ifaces, interface); +if(false && /*interface != "" && */!contains(ifaces, interface)) ifaces = add(ifaces, interface); - y2debug("ifaces=%1", ifaces); - y2internal("ifaces=%1", ifaces); - ifaces = maplist(string e, (list<string>) ifaces, { - return `item(`id(sformat("%1", e)), sformat("%1", e), e == interface); - }); - y2debug("ifaces=%1", ifaces); - } +//} - /* FIXME: #27137 */ - UpdateInterfaces(); - if(size(ifaces) < 1) { + /* FIXME: #suse27137 */ +// UpdateInterfaces(); + if(size(items) < 1) { NetworkDevices::Push(); if(Lan::Propose()) { - UpdateInterfaces(); +// UpdateInterfaces(); // list<term (term (string), string, boolean)> string i = ifaces[0, 0, 0]:""; y2milestone("i=%1", i); @@ -148,11 +136,18 @@ ["USERCONTROL", "STARTMODE",], widget_descr); + +// list<string> items = NetworkDevices::List(""); +// y2internal("network devices list %1", items); + +/* NetworkDevices::Read(); - map <string, string> device_descr = GetDeviceDescription(Internet::device); + map <string, string> device_descr = GetDeviceDescription(items[0]:""); y2internal("device_descr %1", device_descr); string connection_text = _("%1 - %2 (%3)"); +*/ +y2internal("interface %1", interface); /* DSL dialog contents */ term contents = `HBox( `HSpacing(6), @@ -167,23 +162,14 @@ /* TextEntry label */ `TextEntry(`id(`vpivci), _("&VPI/VCI"), vpivci), `VSpacing(0.2), + `Frame(_("&Ethernet Card"), `HBox( - /* ComboBox label */ -// `Left(`ReplacePoint(`id(`rp), `ComboBox(`id(`interface), _("&Ethernet Card"), ifaces))), /* 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"))))), +// `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 - `Right(`PushButton(`id(`net_expert), _("&Change Device"))) - /* TextEntry label */ - // `TextEntry(`id(`interface), _("&Ethernet Card"), interface), -// `HSpacing(1), -/* - `VBox( - `Label(""), - `PushButton(`id(`lan), _("&Configure Network Cards")) - ) -*/ - ), +getDeviceContens(interface) + )), + `PushButton(`id(`lan), _("&Configure Network Cards")), `VSpacing(0.2), /* TextEntry label */ `TextEntry(`id(`modemip), _("Modem &IP Address"), modemip) @@ -207,7 +193,7 @@ UI::ChangeWidget (`id ("STARTMODE"), `Value, startmode); UI::ChangeWidget(`id(`vpivci), `Enabled, pppmode == "pppoatm"); - UI::ChangeWidget(`id(`interface), `Enabled, pppmode == "pppoe"); + enableDevices(pppmode == "pppoe" || pppmode == "pptp"); UI::ChangeWidget(`id(`lan), `Enabled, pppmode == "pppoe" || pppmode == "pptp"); UI::ChangeWidget(`id(`modemip), `Enabled, pppmode == "pptp"); @@ -225,7 +211,7 @@ else if(ret == `next) { /* check_* */ pppmode = (string) UI::QueryWidget(`id(`pppmode), `Value); - interface = (string) UI::QueryWidget(`id(`interface), `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 == "") { @@ -251,7 +237,8 @@ else if(ret == `pppmode) { pppmode = (string) UI::QueryWidget(`id(`pppmode), `Value); UI::ChangeWidget(`id(`vpivci), `Enabled, pppmode == "pppoatm"); - UI::ChangeWidget(`id(`interface), `Enabled, pppmode == "pppoe" || pppmode == "pptp"); + 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; @@ -261,11 +248,14 @@ NetworkDevices::Push(); Call::Function("lan_proposal", ["AskUser"]); NetworkDevices::Pop(); - interface = (string) UI::QueryWidget(`id(`interface), `Value); - UpdateInterfaces(); - UI::ReplaceWidget(`id(`rp), `ComboBox(`id(`interface), _("&Ethernet Card"), ifaces)); + 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; @@ -277,7 +267,7 @@ DSL::pppmode = pppmode; if(pppmode == "pppoe" || pppmode == "pptp") { - DSL::interface = (string) UI::QueryWidget(`id(`interface), `Value); + 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 ()) Modified: trunk/network/src/installation/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/installation/dialogs.... ============================================================================== --- trunk/network/src/installation/dialogs.ycp (original) +++ trunk/network/src/installation/dialogs.ycp Thu May 31 17:46:34 2007 @@ -21,6 +21,7 @@ import "String"; import "Wizard"; include "network/routines.ycp"; +include "network/widgets.ycp"; /** * Ask for password if required @@ -57,37 +58,6 @@ return ret == `ok; } -define map <string, string> GetDeviceDescription(string device_id) { - - string device_name = NetworkDevices::GetValue(device_id,"NAME"); - - if ( (device_name == nil) || (device_name == "") ) { - //TRANSLATORS: Informs that device name is not known - device_name = _("Unknown device"); - } - //avoid too long device names - if (size(device_name) > 30) { - device_name = substring (device_name, 0, 27) + "..."; - } - - string ip_addr = (NetworkDevices::GetValue(device_id, "BOOTPROTO") == "dhcp" ? - // TRANSLATORS: Informs that the IP address is assigned via DHCP - _("DHCP address") : - NetworkDevices::GetValue(device_id, "IPADDR")); - if ( (ip_addr == nil) || (ip_addr == "")) { - //TRANSLATORS: Informs that no IP has been assigned to the device - ip_addr = _("No IP address assigned"); - } - - map <string, string> ret = $[ - - "type" : NetworkDevices::GetDeviceType(device_id), - "name" : device_name, - "ipaddr" : ip_addr, - ]; - - return ret; -} /** * Connection steps dialog @@ -126,24 +96,21 @@ activate the test procedure."), ]; - if(haskey(labels, Internet::type)) - label = labels[Internet::type]:""; + if(haskey(labels, Internet::type)) label = labels[Internet::type]:""; + +list<string> items = getEthernetItems(); boolean already_up = false; if(!Mode::test ()) already_up = Internet::Status(); - /* Label text - selected network device to network test */ - string connection_text = _("&Yes, Test Connection to the Internet\nvia %1 - %2 (%3)"); - map <string, string> device_descr = GetDeviceDescription(Internet::device); - +string current = Internet::device; /* Radiobuttons */ term buttons = `VBox( `VSpacing(1), /* RadioButton label */ - `Left(`ReplacePoint(`id(`rp), `RadioButton(`id(`yes), sformat(connection_text, device_descr["name"]:"", device_descr["type"]:"", device_descr["ipaddr"]:_("No IP address assigned")), Internet::do_test))), - // push button label - `Right(`PushButton(`id(`net_expert), _("&Change Device"))), + `Left(`RadioButton(`id(`yes), `opt(`notify), _("&Yes, Test Connection to the Internet via"), Internet::do_test)), + getDeviceContens(current), /* RadioButton label */ - `Left(`RadioButton(`id(`no), _("N&o, Skip This Test"), !Internet::do_test)), + `Left(`RadioButton(`id(`no), `opt(`notify), _("N&o, Skip This Test"), !Internet::do_test)), `VSpacing(1) ); @@ -190,55 +157,41 @@ Wizard::SetContents(caption, contents, help, true, true); Wizard::SetTitleIcon ("yast-network"); +initDevice(items); - list<string> items = NetworkDevices::List(""); - items = filter (string i, items, ``( i != "lo" )); - y2milestone("network devices list %1", items); - if (items == [] || items == ["lo"]) // #146167 - { - // no interesting ifcfgs, ask ip - items = Internet::GetDevices (); - } - //If only one device is present, disable "Change device" button - if (size(items) <= 1){ - UI::ChangeWidget(`id(`net_expert),`Enabled,false); - } - - any ret = nil; - - while(true) + symbol ret = nil; + boolean exit=false; + do { - ret = UI::UserInput(); - - if (ret == `net_expert) + ret = (symbol)UI::UserInput(); + switch( ret ) { - import "NetworkPopup"; - // popup dialog title - string via_device = NetworkPopup::ChooseItem(_("Network Device Select"), items, Internet::device); - if (via_device != nil) - { - map <string, string> device_descr = GetDeviceDescription(via_device); - Internet::SetDevice( via_device ); - UI::ReplaceWidget(`id(`rp), `RadioButton(`id(`yes), sformat(connection_text, device_descr["name"]:"", device_descr["type"]:"", device_descr["ipaddr"]:""), Internet::do_test)); - y2milestone("selected network device :%1", via_device); - } - } - else if (ret == `abort || ret == `cancel) - { - if (Popup::ConfirmAbort (`incomplete)) + case `net_expert : + current = handleDevice(items, current); break; - } - else if (ret == `next || ret == `back) - { + case `abort: + case `cancel: + if (Popup::ConfirmAbort (`incomplete)){ + exit=true; + break; + } + case `next: + case `back: + exit=true; break; + case `yes: + enableDevices(true); + break; + case `no: + enableDevices(false); + break; + default: + y2error("Unexpected return code:%1", ret); + } - else - { - y2error("Unexpected return code: %1", ret); - } - } + }while(!exit); Internet::do_test = UI::QueryWidget(`id(`rb), `CurrentButton) == `yes; y2debug("Internet::do_test=%1", Internet::do_test); Modified: trunk/network/src/modules/Lan.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/modules/Lan.ycp?rev=3... ============================================================================== --- trunk/network/src/modules/Lan.ycp (original) +++ trunk/network/src/modules/Lan.ycp Thu May 31 17:46:34 2007 @@ -1712,10 +1712,11 @@ /* Some HW found -> use it for proposal */ if(size(Hardware) > 0) { - if (Arch::s390()){ +// if (Arch::s390()){ // tosel = FindMatchingDevice( $["device":sformat("%1-id-%2",InstallInf["module"]:"", InstallInf["hwaddr"]:"")] ); - } - else tosel = FindMatchingDevice($[]); +// } +// else + tosel = FindMatchingDevice($[]); } Modified: trunk/network/src/routines/widgets.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/routines/widgets.ycp?... ============================================================================== --- trunk/network/src/routines/widgets.ycp (original) +++ trunk/network/src/routines/widgets.ycp Thu May 31 17:46:34 2007 @@ -16,6 +16,8 @@ // This is just a start. import "IP"; +import "NetworkPopup"; +import "NetworkDevices"; /** * Validator for IP adresses, no_popup @@ -78,26 +80,6 @@ "opt": [], "help": _("<p>H</p>"), ], -/* - "": $[ - "widget": `, - "label": _(""), - "opt": [], - "help": _("<p>H</p>"), - ], - "": $[ - "widget": `, - "label": _(""), - "opt": [], - "help": _("<p>H</p>"), - ], - "": $[ - "widget": `, - "label": _(""), - "opt": [], - "help": _("<p>H</p>"), - ], -*/ ]; /** @@ -200,5 +182,87 @@ return ret; } + +define string GetDeviceDescription(string device_id) { + string device_name = NetworkDevices::GetValue(device_id,"NAME"); + if ( (device_name == nil) || (device_name == "") ) { + //TRANSLATORS: Informs that device name is not known + device_name = _("Unknown device"); + } + //avoid too long device names + if (size(device_name) > 30) { + device_name = substring (device_name, 0, 27) + "..."; + } + string ip_addr = (NetworkDevices::GetValue(device_id, "BOOTPROTO") == "dhcp" ? + // TRANSLATORS: Informs that the IP address is assigned via DHCP + _("DHCP address") : + NetworkDevices::GetValue(device_id, "IPADDR")); + if ( (ip_addr == nil) || (ip_addr == "")) { + //TRANSLATORS: Informs that no IP has been assigned to the device + ip_addr = _("No IP address assigned"); + } + string output = sformat(_("%1 - %2 (%3)"), + device_name, NetworkDevices::GetDeviceType(device_id), ip_addr); + return output; +} + + + +list<string> getEthernetItems(){ + NetworkDevices::Read(); + list<string> items = NetworkDevices::List("eth"); + items = filter (string i, items, ``( i != "lo" )); + y2internal("network devices list %1", items); + return items; +} + +list<string> getNetDeviceItems(){ + NetworkDevices::Read(); + list<string> ifaces = NetworkDevices::List("eth"); + y2debug("ifaces=%1", ifaces); + ifaces = (list<string>)union((list)ifaces, (NetworkDevices::List("eth-pcmcia"))); + y2debug("ifaces=%1", ifaces); + ifaces = (list<string>)union((list)ifaces, NetworkDevices::List("eth-usb")); + ifaces = (list<string>)union((list)ifaces, NetworkDevices::List("wlan")); // #186102 + y2debug("ifaces=%1", ifaces); + return ifaces; +} + +term getDeviceContens(string selected){ +return `VBox( + `VSpacing(1), + `Left(`Label(`id(`net_device), GetDeviceDescription(selected))), + `Right(`PushButton(`id(`net_expert), _("&Change Device"))), + `VSpacing(1) + ); +} + + +void initDevice(list<string> items){ + //If only one device is present, disable "Change device" button + if (size(items) <= 1) UI::ChangeWidget(`id(`net_expert),`Enabled,false); +} + +void enableDevices(boolean enable){ + UI::ChangeWidget(`net_device, `Enabled, enable); + UI::ChangeWidget(`net_expert, `Enabled, enable); +} + +void refreshDevice(string via_device){ + UI::ChangeWidget(`net_device, `Value, GetDeviceDescription(via_device)); +} + +string handleDevice(list<string>items, string selected){ + // popup dialog title + string via_device = NetworkPopup::ChooseItem(_("Network Device Select"), items, selected); + if (via_device != nil) + { + UI::ChangeWidget(`net_device, `Value, GetDeviceDescription(via_device)); + y2milestone("selected network device :%1", via_device); + selected = via_device; + } + return selected; +} + /* EOF */ } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mzugec@svn.opensuse.org