Module: Yast::NetworkWidgetsInclude
- Defined in:
- ../../src/include/network/widgets.rb
Instance Method Summary (collapse)
-
- (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) getDeviceContens(selected)
- - (Object) GetDeviceDescription(device_id)
- - (Object) getInternetItems
- - (Object) getNetDeviceItems
- - (Object) handleDevice(items, selected)
- - (Object) initDevice(items)
- - (Object) initialize_network_widgets(include_target)
- - (Object) MakeStartmode(ids)
- - (Object) refreshDevice(via_device)
-
- (Object) ValidateIP(key, event)
Validator for IP adresses, no_popup.
Instance Method Details
- (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)
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File '../../src/include/network/widgets.rb', line 364 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)
330 331 332 333 334 335 |
# File '../../src/include/network/widgets.rb', line 330 def enableDevices(enable) UI.ChangeWidget(:net_device, :Enabled, enable) UI.ChangeWidget(:net_expert, :Enabled, enable) nil end |
- (Object) getDeviceContens(selected)
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File '../../src/include/network/widgets.rb', line 299 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)
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 |
# File '../../src/include/network/widgets.rb', line 234 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
268 269 270 271 272 273 |
# File '../../src/include/network/widgets.rb', line 268 def getInternetItems NetworkInterfaces.Read items = NetworkInterfaces.List("") items = Builtins.filter(items) { |i| i != "lo" } deep_copy(items) end |
- (Object) getNetDeviceItems
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File '../../src/include/network/widgets.rb', line 275 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)
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File '../../src/include/network/widgets.rb', line 343 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) initDevice(items)
320 321 322 323 324 325 326 327 328 |
# File '../../src/include/network/widgets.rb', line 320 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)
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 |
# File '../../src/include/network/widgets.rb', line 31 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 "LanItems" Yast.include include_target, "network/complex.rb" @widget_descr = { "USERCONTROL" => { "widget" => :checkbox, # CheckBox label # is the interface administrable by users (as opposed to root) "label" => _( "E&nable Device Control for Non-root User Via QInternet" ), "opt" => [:notify], "help" => # Details dialog help _( "<p><b><big>Device Control</big></b></p>\n" + "<p>Usually, only the system administrator is allowed to activate and\n" + "deactivate a network interface. With <b>Enable Device Control for Non-root User\n" + "Via QInternet</b>, any user may control the interface via QInternet.This will require\n" + "<b>smpppd</b> installed and running.</p>\n" ) }, # #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) MakeStartmode(ids)
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 |
# File '../../src/include/network/widgets.rb', line 197 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" ), "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) refreshDevice(via_device)
337 338 339 340 341 |
# File '../../src/include/network/widgets.rb', line 337 def refreshDevice(via_device) UI.ChangeWidget(:net_device, :Value, GetDeviceDescription(via_device)) nil end |
- (Object) ValidateIP(key, event)
Validator for IP adresses, no_popup
190 191 192 193 194 195 |
# File '../../src/include/network/widgets.rb', line 190 def ValidateIP(key, event) event = deep_copy(event) value = Convert.to_string(UI.QueryWidget(Id(key), :Value)) return IP.Check(value) if value != "" true end |