Module: Yast::NetworkWidgetsInclude
- Defined in:
- ../../src/include/network/widgets.rb
Instance Method Summary (collapse)
- - (Object) common_mtu_items
-
- (Object) CreateSlaveItems(itemIds, enslavedIfaces)
Builds content for slave configuration dialog (used e.g. when configuring bond slaves) according the given list of itemIds (see LanItems::Items).
- - (Object) enableDevices(enable)
- - (Object) firewall_widget
- - (Object) getDeviceContens(selected)
- - (Object) GetDeviceDescription(device_id)
- - (Object) getInternetItems
- - (Object) getNetDeviceItems
- - (Object) handleDevice(items, selected)
- - (Object) handleIPv6(key, event)
- - (Object) handleStartmode(key, event)
- - (Object) init_ipoib_mode_widget(key)
- - (Object) initDevice(items)
- - (Object) initialize_network_widgets(include_target)
- - (Object) initIPv6(key)
- - (Object) ipoib_mode_widget
- - (Object) ipoib_mtu_items
- - (Object) ipv6_widget
- - (Object) MakeStartmode(ids)
- - (Object) managed_widget
-
- (Object) ManagedInit(key)
Initialize the NetworkManager widget.
-
- (Object) ManagedStore(key, event)
Store the NetworkManager widget.
- - (Object) mtu_widget
- - (Object) refreshDevice(via_device)
- - (Object) store_ipoib_mode_widget(key, event)
- - (Object) storeIPv6(key, event)
-
- (Object) ValidateIP(key, event)
Validator for IP adresses, no_popup.
Instance Method Details
- (Object) common_mtu_items
263 264 265 266 267 268 269 270 |
# File '../../src/include/network/widgets.rb', line 263 def common_mtu_items [ # translators: MTU value description (size in bytes, desc) ["1500", _("1500 (Ethernet, DSL broadband)")], ["1492", _("1492 (PPPoE broadband)")], ["576", _("576 (dial-up)")] ] end |
- (Object) CreateSlaveItems(itemIds, enslavedIfaces)
Builds content for slave configuration dialog (used e.g. when configuring bond slaves) according the given list of itemIds (see LanItems::Items)
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File '../../src/include/network/widgets.rb', line 561 def CreateSlaveItems(itemIds, enslavedIfaces) itemIds = deep_copy(itemIds) enslavedIfaces = deep_copy(enslavedIfaces) items = [] Builtins.foreach(itemIds) do |itemId| description = "" dev_name = LanItems.GetDeviceName(itemId) ifcfg = LanItems.GetDeviceMap(itemId) next if IsEmpty(dev_name) ifcfg = { "dev_name" => dev_name } if ifcfg == nil dev_type = LanItems.GetDeviceType(itemId) if Builtins.contains(["tun", "tap"], dev_type) description = NetworkInterfaces.GetDevTypeDescription(dev_type, true) else description = BuildDescription( "", "", ifcfg, [Ops.get_map(LanItems.GetLanItem(itemId), "hwinfo", {})] ) # this conditions origin from bridge configuration # if enslaving a configured device then its configuration is rewritten # to "0.0.0.0/32" if Ops.get_string(ifcfg, "IPADDR", "") != "0.0.0.0" description = Builtins.sformat("%1 (%2)", description, "configured") end end selected = Builtins.contains(enslavedIfaces, dev_name) items = Builtins.add( items, Item( Id(dev_name), Builtins.sformat("%1 - %2", dev_name, description), selected ) ) end deep_copy(items) end |
- (Object) enableDevices(enable)
527 528 529 530 531 532 |
# File '../../src/include/network/widgets.rb', line 527 def enableDevices(enable) UI.ChangeWidget(:net_device, :Enabled, enable) UI.ChangeWidget(:net_expert, :Enabled, enable) nil end |
- (Object) firewall_widget
254 255 256 257 258 259 260 261 |
# File '../../src/include/network/widgets.rb', line 254 def if SuSEFirewall4Network.IsInstalled SuSEFirewall4Network.FirewallZonesComboBoxItems else [["", _("Firewall is not installed.")]] end end |
- (Object) getDeviceContens(selected)
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File '../../src/include/network/widgets.rb', line 496 def getDeviceContens(selected) VBox( VSpacing(0.5), HBox( HSpacing(3), MinWidth( 30, Label( Id(:net_device), Opt(:hstretch), GetDeviceDescription(selected) ) ), HSpacing(1), PushButton(Id(:net_expert), _("&Change Device")) ), VSpacing(0.5) ) end |
- (Object) GetDeviceDescription(device_id)
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File '../../src/include/network/widgets.rb', line 431 def GetDeviceDescription(device_id) device_name = NetworkInterfaces.GetValue(device_id, "NAME") if device_name == nil || device_name == "" #TRANSLATORS: Informs that device name is not known device_name = _("Unknown device") end Builtins.y2milestone("device_name %1", device_name) #avoid too long device names #if (size(device_name) > 30) { # device_name = substring (device_name, 0, 27) + "..."; #} ip_addr = Builtins.issubstring( NetworkInterfaces.GetValue(device_id, "BOOTPROTO"), "dhcp" ) ? # TRANSLATORS: Part of label, device with IP address assigned by DHCP _("DHCP address") : # TRANSLATORS: Part of label, device with static IP address NetworkInterfaces.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") end output = Builtins.sformat( _("%1 \n%2 - %3"), device_name, NetworkInterfaces.GetDeviceTypeName(device_id), ip_addr ) output end |
- (Object) getInternetItems
465 466 467 468 469 470 |
# File '../../src/include/network/widgets.rb', line 465 def getInternetItems NetworkInterfaces.Read items = NetworkInterfaces.List("") items = Builtins.filter(items) { |i| i != "lo" } deep_copy(items) end |
- (Object) getNetDeviceItems
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File '../../src/include/network/widgets.rb', line 472 def getNetDeviceItems NetworkInterfaces.Read ifaces = NetworkInterfaces.List("eth") Builtins.y2debug("ifaces=%1", ifaces) ifaces = Convert.convert( Builtins.union(ifaces, NetworkInterfaces.List("eth-pcmcia")), :from => "list", :to => "list <string>" ) Builtins.y2debug("ifaces=%1", ifaces) ifaces = Convert.convert( Builtins.union(ifaces, NetworkInterfaces.List("eth-usb")), :from => "list", :to => "list <string>" ) ifaces = Convert.convert( Builtins.union(ifaces, NetworkInterfaces.List("wlan")), :from => "list", :to => "list <string>" ) # #186102 Builtins.y2debug("ifaces=%1", ifaces) deep_copy(ifaces) end |
- (Object) handleDevice(items, selected)
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File '../../src/include/network/widgets.rb', line 540 def handleDevice(items, selected) items = deep_copy(items) # popup dialog title via_device = NetworkPopup.ChooseItem( _("Network Device Select"), items, selected ) if via_device != nil UI.ChangeWidget(:net_device, :Value, GetDeviceDescription(via_device)) Builtins.y2milestone("selected network device :%1", via_device) selected = via_device end selected end |
- (Object) handleIPv6(key, event)
394 395 396 397 398 399 400 |
# File '../../src/include/network/widgets.rb', line 394 def handleIPv6(key, event) event = deep_copy(event) if Ops.get_string(event, "EventReason", "") == "ValueChanged" Lan.SetIPv6(Convert.to_boolean(UI.QueryWidget(Id(:ipv6), :Value))) end nil end |
- (Object) handleStartmode(key, event)
181 182 183 184 185 186 187 188 |
# File '../../src/include/network/widgets.rb', line 181 def handleStartmode(key, event) UI.ChangeWidget( Id("IFPLUGD_PRIORITY"), :Enabled, UI.QueryWidget(Id("STARTMODE"), :Value) == "ifplugd" ) nil end |
- (Object) init_ipoib_mode_widget(key)
226 227 228 229 230 231 232 233 234 235 236 237 |
# File '../../src/include/network/widgets.rb', line 226 def (key) ipoib_mode = LanItems.ipoib_mode return unless LanItems.ipoib_modes.keys.include?(ipoib_mode) UI.ChangeWidget( Id(key), :CurrentButton, ipoib_mode ) end |
- (Object) initDevice(items)
517 518 519 520 521 522 523 524 525 |
# File '../../src/include/network/widgets.rb', line 517 def initDevice(items) items = deep_copy(items) #If only one device is present, disable "Change device" button if Ops.less_or_equal(Builtins.size(items), 1) UI.ChangeWidget(Id(:net_expert), :Enabled, false) end nil end |
- (Object) initialize_network_widgets(include_target)
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 |
# File '../../src/include/network/widgets.rb', line 32 def (include_target) Yast.import "UI" textdomain "network" # Gradually all yast2-network UI will be converted to CWM # for easier maintenance. # This is just a start. Yast.import "IP" Yast.import "NetworkPopup" Yast.import "NetworkInterfaces" Yast.import "NetworkService" Yast.import "Lan" Yast.import "LanItems" Yast.include include_target, "network/complex.rb" @widget_descr = { # #23315 "DIALPREFIXREGEX" => { "widget" => :textentry, # TextEntry label "label" => _("&Dial Prefix Regular Expression"), "help" => # dial prefix regex help _( "<p>When <b>Dial Prefix Regular Expression</b> is set, users can\n" + "change the dial prefix in KInternet provided that it matches the expression.\n" + "A recommended value is <tt>[09]?</tt>, allowing <tt>0</tt>, <tt>9</tt>,\n" + "and the empty prefix. If the expression is empty, users are not allowed\n" + "to change the prefix.</p>\n" ) }, # obsoleted by BOOTPROTO_* "BOOTPROTO" => { "widget" => :radio_buttons, # radio button group label,method of setup "label" => _( "Setup Method" ), # is this necessary? "items" => [ # radio button label ["dhcp", _("A&utomatic Address Setup (via DHCP)")], # radio button label ["static", _("S&tatic Address Setup")] ], "opt" => [], "help" => _("<p>H</p>") } } # This is the data for widget_descr["STARTMODE"]. # It is separated because the list of items depends on the device type # and will be substituted dynamically. # Helps are rich text, but not paragraphs. @startmode_items = { # onboot, on and boot are aliases for auto # See NetworkInterfaces::CanonicalizeStartmode "auto" => # is a part of the static help text { # Combo box option for Device Activation "label" => _( "At Boot Time" ), "help" => "" }, "off" => # is a part of the static help text { "label" => _("Never"), "help" => "" }, "managed" => { # Combo box option for Device Activation # DO NOT TRANSLATE NetworkManager, it is a program name "label" => _( "By NetworkManager" ), # help text for Device Activation # DO NOT TRANSLATE NetworkManager, it is a program name "help" => _( "<b>By NetworkManager</b>: a desktop applet\ncontrols the interface. There is no need to set it up in YaST." ) }, "manual" => { # Combo box option for Device Activation "label" => _("Manually"), # help text for Device Activation "help" => _( "<p><b>Manually</b>: You control the interface manually\nvia 'ifup' or 'qinternet' (see 'User Controlled' below).</p>\n" ) }, "ifplugd" => { # Combo box option for Device Activation "label" => _( "On Cable Connection" ), # help text for Device Activation "help" => _( "<b>On Cable Connection</b>:\n" + "The interface is watched for whether there is a physical\n" + "network connection. That means either the cable is connected or the\n" + "wireless interface can connect to an access point.\n" ) }, "hotplug" => { # Combo box option for Device Activation "label" => _("On Hotplug"), # help text for Device Activation "help" => _( "With <b>On Hotplug</b>,\n" + "the interface is set up as soon as it is available. This is\n" + "nearly the same as 'At Boot Time', but does not result in an error at\n" + "boot time if the interface is not present.\n" ) }, "nfsroot" => { # Combo box option for Device Activation "label" => _("On NFSroot"), # help text for Device Activation "help" => _( "Using <b>On NFSroot</b> is similar to <tt>auto</tt>. Interfaces with this startmode will never\n" + "be shut down via <tt>rcnetwork stop</tt>. <tt>ifdown <iface></tt> is still available.\n" + "Use this if you have an NFS or iSCSI root filesystem.\n" ) }, "nfsroot" => { # Combo box option for Device Activation "label" => _("On NFSroot"), # help text for Device Activation "help" => _( "Using <b>On NFSroot</b> is nearly like 'auto'. But interfaces with this startmode will never\n" + "be shut down via 'rcnetwork stop'. 'ifdown <iface>' still works.\n" + "Use this when you have a nfs or iscsi root filesystem.\n" ) } } end |
- (Object) initIPv6(key)
388 389 390 391 392 |
# File '../../src/include/network/widgets.rb', line 388 def initIPv6(key) UI.ChangeWidget(Id(:ipv6), :Value, Lan.ipv6 ? true : false) nil end |
- (Object) ipoib_mode_widget
243 244 245 246 247 248 249 250 251 252 |
# File '../../src/include/network/widgets.rb', line 243 def { "widget" => :radio_buttons, "items" => LanItems.ipoib_modes.to_a, "label" => _("IPoIB Device Mode"), "opt" => [:hstretch], "init" => fun_ref(method(:init_ipoib_mode_widget), "void (string)"), "store" => fun_ref(method(:store_ipoib_mode_widget), "void (string, map)") } end |
- (Object) ipoib_mtu_items
272 273 274 275 276 277 278 |
# File '../../src/include/network/widgets.rb', line 272 def ipoib_mtu_items [ # translators: MTU value description (size in bytes, desc) ["65520", _("65520 (IPoIB in connected mode)")], ["2044", _("2044 (IPoIB in datagram mode)")] ] end |
- (Object) ipv6_widget
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File '../../src/include/network/widgets.rb', line 413 def { "widget" => :custom, "custom_widget" => Frame( _("IPv6 Protocol Settings"), Left(CheckBox(Id(:ipv6), Opt(:notify), _("Enable IPv6"))) ), "opt" => [], "help" => Ops.get_string(@help, "ipv6", ""), "init" => fun_ref(method(:initIPv6), "void (string)"), "handle" => fun_ref( method(:handleIPv6), "symbol (string, map)" ), "store" => fun_ref(method(:storeIPv6), "void (string, map)") } end |
- (Object) MakeStartmode(ids)
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 |
# File '../../src/include/network/widgets.rb', line 190 def MakeStartmode(ids) ids = deep_copy(ids) ret = { "widget" => :combobox, # Combo box label - when to activate device (e.g. on boot, manually, never,..) "label" => _("Activate &Device"), "opt" => [:notify], "handle" => fun_ref(method(:handleStartmode), "symbol (string, map)"), "help" => # Device activation main help. The individual parts will be # substituted as %1 _( "<p><b><big>Device Activation</big></b></p> \n" + "<p>Choose when to bring up the network interface. <b>At Boot Time</b> activates it during system boot, \n" + "<b>Never</b> does not start the device.\n" + "%1</p>\n" ) } helps = "" items = Builtins.maplist(ids) do |id| helps = Ops.add( Ops.add(helps, " "), Ops.get(@startmode_items, [id, "help"], "") ) [id, Ops.get(@startmode_items, [id, "label"], "")] end Ops.set( ret, "help", Builtins.sformat(Ops.get_string(ret, "help", "%1"), helps) ) Ops.set(ret, "items", items) deep_copy(ret) end |
- (Object) managed_widget
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File '../../src/include/network/widgets.rb', line 367 def { "widget" => :custom, "custom_widget" => Frame( _("General Network Settings"), Left( ComboBox( Id(:managed), Opt(:hstretch), _("Network Setup Method"), [] ) ) ), "opt" => [], "help" => @help["managed"] || "", "init" => fun_ref(method(:ManagedInit), "void (string)"), "store" => fun_ref(method(:ManagedStore), "void (string, map)") } end |
- (Object) ManagedInit(key)
Initialize the NetworkManager widget
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File '../../src/include/network/widgets.rb', line 293 def ManagedInit(key) items = [] if NetworkService.is_backend_available(:network_manager) items << Item( Id("managed"), # the user can control the network with the NetworkManager program _("NetworkManager Service"), NetworkService.is_network_manager ) end if NetworkService.is_backend_available(:netconfig) items << Item( Id("ifup"), # ifup is a program name _("Traditional ifup"), NetworkService.is_netconfig ) end if NetworkService.is_backend_available(:wicked) items << Item( Id("wicked"), # wicked is network configuration backend like netconfig _("Wicked Service"), NetworkService.is_wicked ) end items << Item( Id("disabled"), # used when no network service is active or to disable network service _("Network Services Disabled"), NetworkService.is_disabled ) UI.ChangeWidget(Id(:managed), :Items, items) nil end |
- (Object) ManagedStore(key, event)
Store the NetworkManager widget
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File '../../src/include/network/widgets.rb', line 336 def ManagedStore(key, event) new_backend = UI.QueryWidget(Id(:managed), :Value) case new_backend when "ifup" NetworkService.use_netconfig when "managed" NetworkService.use_network_manager when "wicked" NetworkService.use_wicked else NetworkService.disable end if NetworkService.Modified LanItems.SetModified if Stage.normal && NetworkService.is_network_manager Popup.AnyMessage( _("Applet needed"), _( "NetworkManager is controlled by desktop applet\n" + "(KDE plasma widget and nm-applet for GNOME).\n" + "Be sure it's running and if not, start it manually." )) end end nil end |
- (Object) mtu_widget
280 281 282 283 284 285 286 287 288 289 |
# File '../../src/include/network/widgets.rb', line 280 def { "widget" => :combobox, # textentry label, Maximum Transfer Unit "label" => _("Set &MTU"), "opt" => [:hstretch, :editable], "items" => [], "help" => @help["mtu"] || "" } end |
- (Object) refreshDevice(via_device)
534 535 536 537 538 |
# File '../../src/include/network/widgets.rb', line 534 def refreshDevice(via_device) UI.ChangeWidget(:net_device, :Value, GetDeviceDescription(via_device)) nil end |
- (Object) store_ipoib_mode_widget(key, event)
239 240 241 |
# File '../../src/include/network/widgets.rb', line 239 def (key, event) LanItems.ipoib_mode = UI.QueryWidget(Id(key), :CurrentButton) end |
- (Object) storeIPv6(key, event)
402 403 404 405 406 407 408 409 410 411 |
# File '../../src/include/network/widgets.rb', line 402 def storeIPv6(key, event) event = deep_copy(event) if Convert.to_boolean(UI.QueryWidget(Id(:ipv6), :Value)) Lan.SetIPv6(true) else Lan.SetIPv6(false) end nil end |
- (Object) ValidateIP(key, event)
Validator for IP adresses, no_popup
175 176 177 178 179 |
# File '../../src/include/network/widgets.rb', line 175 def ValidateIP(key, event) value = Convert.to_string(UI.QueryWidget(Id(key), :Value)) return IP.Check(value) if value != "" true end |