Class: Yast::InternetDevicesClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/InternetDevices.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) FindFastest

Find the fastest connection to the Internet

Returns:

  • true if a “good” connection was found



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File '../../src/modules/InternetDevices.rb', line 91

def FindFastest
  Reset()

  NetworkInterfaces.Read
  Internet.device = NetworkInterfaces.Fastest

  if Internet.device == ""
    Internet.device = Ops.get(Internet.GetDevices, 0, "")
  end

  Builtins.y2milestone("fastest=%1", Internet.device)

  # No fallback since there are devices that must not be tested (e.g. lo)
  return false if Internet.device == ""

  SetDevice(Internet.device)
  true
end

- (Object) main



34
35
36
37
# File '../../src/modules/InternetDevices.rb', line 34

def main
  Yast.import "Internet"
  Yast.import "NetworkInterfaces"
end

- (Object) Reset

Reset values.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File '../../src/modules/InternetDevices.rb', line 40

def Reset
  Internet.device = ""
  Internet.type = ""
  Internet.logfile = ""
  Internet.provider = ""
  Internet.password = ""
  Internet.demand = false
  Internet.askpassword = nil
  Internet.capi_adsl = false
  Internet.capi_isdn = false

  nil
end

- (Object) SetDevice(dev)

Set device from argument as default network device



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
# File '../../src/modules/InternetDevices.rb', line 55

def SetDevice(dev)
  Internet.device = dev
  NetworkInterfaces.Select(Internet.device)
  Internet.type = NetworkInterfaces.FastestType(Internet.device)
  Internet.provider = Ops.get_string(
    NetworkInterfaces.Current,
    "PROVIDER",
    ""
  )

  if Internet.provider != ""
    Yast.import "Provider"

    Provider.Read
    Provider.Select(Internet.provider)

    Internet.demand = Ops.get_string(Provider.Current, "DEMAND", "no") == "yes"
    Internet.password = Ops.get_string(Provider.Current, "PASSWORD", "")
    Internet.askpassword = Ops.get_string(
      Provider.Current,
      "ASKPASSWORD",
      "no"
    ) == "yes"
    Internet.capi_adsl = Ops.get_string(
      Provider.Current,
      "PPPMODE",
      "pppoe"
    ) == "capi-adsl"
    Internet.capi_isdn = Ops.get_string(Provider.Current, "PPPMODE", "ippp") == "capi-isdn"
  end

  nil
end