Class List Method List File List

# Module: Yast::NtpClientWidgetsInclude

Defined in:
  ../../src/include/ntp-client/widgets.rb

## Instance Method Summary (collapse)

- - (Object) addressInit(id)

  Initialize the widget.

- - (Object) addressStore(id, event)

  Store settings of the widget.

- - (Symbol) browseButtonHandle(id, event)

  Handle function of the widget.

- - (Boolean) CheckCurrentSimpleConfiguration(check_the_server)

  Checks the current simple configuration filled in UI.

- - (Object) chrootInit(id)

  Initialize the widget.

- - (Object) chrootStore(id, event)

  Store settings of the widget.

- - (Symbol) clockTypeHandle(id, event)

  Handle function of the widget.

- - (Object) clockTypeInit(id)

  Initialize the widget.

- - (Object) clockTypeStore(id, event)

  Store settings of the widget.

- - (Symbol) complexButtonHandle(key, event)

  Handle function of the widget.

- - (Symbol) createSymlinkHandle(id, event)

  Handle function of the widget.

- - (Object) createSymlinkInit(id)

  Initialize the widget.

- - (Object) createSymlinkStore(id, event)

  Store settings of the widget.

- - (Object) deviceInit(id)

  Initialize the widget.

- - (Object) deviceStore(id, event)

  Store settings of the widget.

- - (Object) FoundServersHandle(id, event)
- - (Object) FoundServersInit(id)

  Initialize the widget.

- - (Object) FoundServersStore(id, event)

  Store settings of the widget.

- - (Object) FoundServersValidate(id, event)
- - (Symbol) fudgeButtonHandle(key, event)

  Handle function of the widget.

- - (Object) initialize_ntp_client_widgets(include_target)
- - (Object) InitWidgets

  Initialize all widgets.

- - (Object) intervalInit(id)

  Initialize the widget.

- - (Object) intervalStore(id, event)

  Store settings of the widget.

- - (Object) LocalSelectTestHandle(id, event)
- - (Symbol) ntpEnabledOrDisabled(id, event)

  Handle function of the widget.

- - (Object) optionsInit(id)

  Initialize the widget.

- - (Object) optionsStore(id, event)

  Store settings of the widget.

- - (Object) overviewHandle(id, event)

  Handle events on the widget.

- - (Object) overviewInit(id)

  Initialize the widget.

- - (Object) overviewRedraw

  Redraw the overview table.

- - (Symbol) peerTypesHandle(id, event)

  Handle events on the widget.

- - (Object) peerTypesInit(id)

  Initialize the widget.

- - (Object) PolicyInit(id)

  Initialize the widget.

- - (Object) PolicyStore(id, event)

  Store settings of the widget.

- - (Object) PublicSelectTestHandle(id, event)
- - (Object) RandomServersHandle(id, event)

  Function handles the “use_random_servers” checkbox.

- - (Object) RandomServersInit(id)
- - (Object) RandomServersStore(id, event)
- - (Object) restrictOptionsInit(id)
- - (Object) restrictOptionsStore(id, event)
- - (Object) secureInit(id)
- - (Object) secureStore(id, event)
- - (Symbol) serverAddressHandle(id, event)

  Handle events on the widget.

- - (Object) ServerAddressIsInConfiguration

  Check the current confifuration and returns whether some server address is defined.

- - (Boolean) serverAddressValidate(id, event)

  Handle events on the widget.

- - (Symbol) ServerListHandle(id, event)

  Handle function of the widget.

- - (Object) ServerListInit(id)

  Initialize the widget.

- - (Object) ServerListStore(id, event)

  Store settings of the widget.

- - (Boolean) ServerListValidate(id, event)

  Validation function of a widget.

- - (Object) ServersSourceInit(id)

  Initialize the widget.

- - (Object) showLogPopup

  Show popup with NTP daemon's log.

- - (Object) SilentWrite

  Save the configuration and restart NTP deamon.

- - (Object) startHandle(id, event)

  Handle function of the widget.

- - (Object) startInit(id)

  Initialize the widget.

- - (Object) startStore(id, event)

  Store settings of the widget.

- - (Symbol) timeSyncOrNo(id, event)

  Handle function of the widget.

- - (Object) unitNumberInit(id)

  Initialize the widget.

- - (Object) unitNumberStore(id, event)

  Store settings of the widget.

## Instance Method Details

### - (`Object`) addressInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    # File '../../src/include/ntp-client/widgets.rb', line 709

    def addressInit(id)
      #remember selected_record_during_init only when the module is started
      ##230240
      if @selected_record_during_init == {}
        @selected_record_during_init = deep_copy(NtpClient.selected_record)
      end

      ad = NtpClient.ad_controller
      if ad != ""
        UI.ChangeWidget(Id(id), :Value, ad)
      else
        UI.ChangeWidget(
          Id(id),
          :Value,
          Ops.get_string(NtpClient.selected_record, "address", "")
        )
      end
      UI.SetFocus(Id(id))

      nil
    end

### - (`Object`) addressStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    # File '../../src/include/ntp-client/widgets.rb', line 734

    def addressStore(id, event)
      event = deep_copy(event)
      # Don't store anything in case of switching to the advanced configuration
      return if Ops.get(event, "ID") == :complex

      Ops.set(
        NtpClient.selected_record,
        "address",
        UI.QueryWidget(Id(id), :Value)
      )
      if NtpClient.simple_dialog
        # Save the server_address only when changed
        # do not re-add it (with defaut values) - bug 177575
        if Ops.get_string(@selected_record_during_init, "address", "") ==
            Ops.get_string(NtpClient.selected_record, "address", "")
          Builtins.y2milestone(
            "The currently selected server is the same as when starting the module..."
          )
        else
          Builtins.y2milestone(
            "Storing the server address in simple configuration"
          )
          Ops.set(NtpClient.selected_record, "type", "server")
        end
      end

      nil
    end

### - (`Symbol`) browseButtonHandle(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always nil

    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    # File '../../src/include/ntp-client/widgets.rb', line 1062

    def browseButtonHandle(id, event)
      event = deep_copy(event)
      current = Convert.to_string(UI.QueryWidget(Id("device"), :Value))
      current = "/dev" if current == ""
      # popup header
      current = UI.AskForExistingFile(current, "", _("Select the Device"))
      UI.ChangeWidget(Id("device"), :Value, current) if current != nil
      nil
    end

### - (`Boolean`) CheckCurrentSimpleConfiguration(check_the_server)

Checks the current simple configuration filled in UI. Selected option RandomPoolServers returns true; Selected valid server address also returns true;

Returns:

- (`Boolean`) —

  whether the configuration is correct

    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
    # File '../../src/include/ntp-client/widgets.rb', line 216

    def CheckCurrentSimpleConfiguration(check_the_server)
      # if the option "random_servers" is selected, do not check the server name
      if UI.WidgetExists(Id("use_random_servers")) &&
          Convert.to_boolean(UI.QueryWidget(Id("use_random_servers"), :Value))
        return true
      end

      server_1 = Convert.to_string(UI.QueryWidget(Id("server_address"), :Value))
      if !check_the_server && server_1 == ""
        Builtins.y2milestone("Not checking an empty server...")
        return true
      end

      server_2 = server_1
      if Builtins.regexpmatch(server_2, "(.*).$")
        server_2 = Builtins.regexpsub(server_2, "(.*).$", "\\1")
      end

      if !Hostname.Check(server_1) && !Hostname.CheckFQ(server_1) &&
          !IP.Check(server_1) &&
          !Hostname.Check(server_2) && !Hostname.CheckFQ(server_2)
        # TRANSLATORS: Popup error message
        Report.Error(
          Builtins.sformat(
            _(
              "NTP server '%1' is not a valid hostname,\nfully qualified hostname, IPv4 address, or IPv6 address."
            ),
            server_1
          )
        )
        return false
      end

      true
    end

### - (`Object`) chrootInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    349
    350
    351
    352
    353
    # File '../../src/include/ntp-client/widgets.rb', line 349

    def chrootInit(id)
      UI.ChangeWidget(Id(id), :Value, NtpClient.run_chroot)

      nil
    end

### - (`Object`) chrootStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    # File '../../src/include/ntp-client/widgets.rb', line 358

    def chrootStore(id, event)
      event = deep_copy(event)
      tmp = NtpClient.run_chroot
      NtpClient.run_chroot = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
      if tmp != NtpClient.run_chroot
        Builtins.y2milestone(
          "set modified from %1 to true 2",
          NtpClient.modified
        )
        NtpClient.modified = true
      end

      nil
    end

### - (`Symbol`) clockTypeHandle(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always nil

    984
    985
    986
    987
    988
    989
    990
    991
    992
    # File '../../src/include/ntp-client/widgets.rb', line 984

    def clockTypeHandle(id, event)
      event = deep_copy(event)
      current = Builtins.tointeger(
        Convert.to_string(UI.QueryWidget(Id(id), :Value))
      )
      hw_avail = Ops.get(@clock_types, [current, "device"], "") != ""
      UI.ChangeWidget(Id("create_symlink"), :Enabled, hw_avail)
      createSymlinkHandle(id, event)
    end

### - (`Object`) clockTypeInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    # File '../../src/include/ntp-client/widgets.rb', line 996

    def clockTypeInit(id)
      UI.ChangeWidget(
        Id(id),
        :Value,
        Builtins.sformat(
          "%1",
          getClockType(Ops.get_string(NtpClient.selected_record, "address", ""))
        )
      )
      clockTypeHandle(id, {})

      nil
    end

### - (`Object`) clockTypeStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    # File '../../src/include/ntp-client/widgets.rb', line 1013

    def clockTypeStore(id, event)
      event = deep_copy(event)
      Ops.set(
        NtpClient.selected_record,
        "address",
        setClockType(
          Ops.get_string(NtpClient.selected_record, "address", ""),
          Builtins.tointeger(Convert.to_string(UI.QueryWidget(Id(id), :Value)))
        )
      )

      nil
    end

### - (`Symbol`) complexButtonHandle(key, event)

Handle function of the widget

Parameters:

- key (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always `complex

    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    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
    332
    333
    334
    335
    336
    # File '../../src/include/ntp-client/widgets.rb', line 282

    def complexButtonHandle(key, event)
      event = deep_copy(event)
      if Ops.get(event, "ID") == "complex_button"
        # true  - check and report the missing server value
        # false - the opposite
        handle_the_server = Convert.to_string(
          UI.QueryWidget(Id("server_address"), :Value)
        ) != ""

        conf_check = CheckCurrentSimpleConfiguration(handle_the_server)
        Builtins.y2milestone(
          "Checking the current simple configuration returned: %1",
          conf_check
        )

        Ops.set(
          NtpClient.selected_record,
          "address",
          UI.QueryWidget(Id("server_address"), :Value)
        )
        # disabled in case of PoolNTPorg feature
        # and in case of missing server value
        if Convert.to_boolean(UI.QueryWidget(Id("server_address"), :Enabled)) &&
            Ops.get(NtpClient.selected_record, "address") != nil &&
            Ops.get_string(NtpClient.selected_record, "address", "") != ""
          # Save the server_address only when changed
          # do not re-add it (with defaut values) - bug 177575
          if Ops.get_string(@selected_record_during_init, "address", "") ==
              Ops.get_string(NtpClient.selected_record, "address", "")
            Builtins.y2milestone(
              "The currently selected server is the same as when starting the module..."
            )
          else
            Ops.set(NtpClient.selected_record, "type", "server")
            Builtins.y2milestone(
              "Storing the current address record: %1",
              NtpClient.selected_record
            )
            NtpClient.storeSyncRecord
          end
          # deleting the current record if current server address is empty
        elsif Ops.get_string(NtpClient.selected_record, "address", "") == ""
          # delete only the server record if there is some current server record
          if ServerAddressIsInConfiguration()
            NtpClient.selected_record = nil
            NtpClient.storeSyncRecord
          end
        end

        Builtins.y2milestone("Switching to advanced configuration...")
        return :complex
      end
      ntpEnabledOrDisabled(key, event)
      nil
    end

### - (`Symbol`) createSymlinkHandle(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always nil

    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    # File '../../src/include/ntp-client/widgets.rb', line 951

    def createSymlinkHandle(id, event)
      event = deep_copy(event)
      active = Convert.to_boolean(UI.QueryWidget(Id("create_symlink"), :Value))
      current = 0
      if id == "clock_type"
        current = Builtins.tointeger(
          Convert.to_string(UI.QueryWidget(Id(id), :Value))
        )
        active = active && Ops.get(@clock_types, [current, "device"], "") == ""
      end
      UI.ChangeWidget(Id("device"), :Enabled, active)
      UI.ChangeWidget(Id("browse"), :Enabled, active)
      nil
    end

### - (`Object`) createSymlinkInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    937
    938
    939
    940
    941
    942
    943
    944
    945
    # File '../../src/include/ntp-client/widgets.rb', line 937

    def createSymlinkInit(id)
      UI.ChangeWidget(
        Id(id),
        :Value,
        Ops.get_boolean(NtpClient.selected_record, "create_symlink", false)
      )

      nil
    end

### - (`Object`) createSymlinkStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    # File '../../src/include/ntp-client/widgets.rb', line 969

    def createSymlinkStore(id, event)
      event = deep_copy(event)
      Ops.set(
        NtpClient.selected_record,
        "create_symlink",
        Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
      )

      nil
    end

### - (`Object`) deviceInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    # File '../../src/include/ntp-client/widgets.rb', line 1074

    def deviceInit(id)
      UI.ChangeWidget(
        Id(id),
        :Value,
        Ops.get_string(NtpClient.selected_record, "device", "")
      )

      nil
    end

### - (`Object`) deviceStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    # File '../../src/include/ntp-client/widgets.rb', line 1087

    def deviceStore(id, event)
      event = deep_copy(event)
      Ops.set(
        NtpClient.selected_record,
        "device",
        Convert.to_string(UI.QueryWidget(Id(id), :Value))
      )

      nil
    end

### - (`Object`) FoundServersHandle(id, event)

    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    # File '../../src/include/ntp-client/widgets.rb', line 1241

    def FoundServersHandle(id, event)
      event = deep_copy(event)
      #    if (event["ID"]:nil == "list_rb" || event["ID"]:nil == "lookup_rb")
      #    {
      #	boolean enabled = (boolean)UI::QueryWidget (`id ("lookup_rb"), `Value);
      #	UI::ChangeWidget (`id ("server_address"), `Enabled, enabled);
      #	UI::ChangeWidget (`id (`lookup_server), `Enabled, enabled);
      #	return nil;
      #    }
      if Ops.get(event, "ID") == :lookup_server
        # TRANSLATORS: Busy message
        UI.OpenDialog(Label(_("Scanning for NTP servers on your network...")))

        method = :slp
        server_names = Builtins.sort(NtpClient.DetectNtpServers(method))
        @found_servers_cache = deep_copy(server_names)

        UI.CloseDialog

        # no server has been found
        if server_names == [] || server_names == nil
          # firewall probably blocks broadcast reply
          if SuSEFirewall.GetStartService
            # TRANSLATORS: Popup error - no NTP server has been found during scanning the network.
            #              There is a very high possibility that is is because of running firewall.
            Report.Error(
              _(
                "No NTP server has been found on your network.\n" +
                  "This could be caused by a running SuSEfirewall2,\n" +
                  "which probably blocks the network scanning."
              )
            )
            # no server is available on the network
          else
            # TRANSLATORS: Popup error - no NTP server has been found during scanning the network.
            Report.Error(_("No NTP server has been found on your network."))
          end
          return nil
        end

        UI.ReplaceWidget(
          :server_address_rp,
          ComboBox(
            Id("server_address"),
            Opt(:editable, :hstretch),
            # combo box label
            _("Address"),
            server_names
          )
        )
        return nil
      end
      nil
    end

### - (`Object`) FoundServersInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    # File '../../src/include/ntp-client/widgets.rb', line 1298

    def FoundServersInit(id)
      items = []

      # fate#302863: suggest ntp.$domain
      if @found_servers_cache == nil
        guessed = Ops.add("ntp.", Hostname.CurrentDomain)
        if NtpClient.TestNtpServer(guessed, :transient_popup)
          @found_servers_cache = [guessed]
        else
          @found_servers_cache = []
        end
      end

      Builtins.foreach(@found_servers_cache) do |server|
        items = Builtins.add(items, Item(Id(server), server))
      end
      UI.ChangeWidget(Id("server_address"), :Items, items)
      FoundServersHandle(id, { "ID" => "list_rb" })

      nil
    end

### - (`Object`) FoundServersStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    # File '../../src/include/ntp-client/widgets.rb', line 1323

    def FoundServersStore(id, event)
      event = deep_copy(event)
      #    if (UI::WidgetExists (`id ("lookup_rb"))
      #    	&& ! (boolean)UI::QueryWidget (`id ("lookup_rb"), `Value))
      #    {
      #    	return;
      #    }
      address = Convert.to_string(UI.QueryWidget(Id("server_address"), :Value))
      Ops.set(NtpClient.selected_record, "address", address)

      nil
    end

### - (`Object`) FoundServersValidate(id, event)

    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    # File '../../src/include/ntp-client/widgets.rb', line 1336

    def FoundServersValidate(id, event)
      event = deep_copy(event)
      #    if (UI::WidgetExists (`id ("lookup_rb"))
      #	&& ! (boolean)UI::QueryWidget (`id ("lookup_rb"), `Value))
      #    {
      #	return true;
      #    }
      server = Convert.to_string(UI.QueryWidget(Id("server_address"), :Value))
      if server == nil || server == ""
        UI.SetFocus(Id("server_address"))
        # popup message
        Popup.Message(_("No server is selected."))
        return false
      end
      true
    end

### - (`Symbol`) fudgeButtonHandle(key, event)

Handle function of the widget

Parameters:

- key (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always `complex

    342
    343
    344
    345
    # File '../../src/include/ntp-client/widgets.rb', line 342

    def fudgeButtonHandle(key, event)
      event = deep_copy(event)
      :fudge
    end

### - (`Object`) initialize_ntp_client_widgets(include_target)

    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
    # File '../../src/include/ntp-client/widgets.rb', line 13

    def initialize_ntp_client_widgets(include_target)
      textdomain "ntp-client"

      Yast.import "Confirm"
      Yast.import "Popup"
      Yast.import "Label"
      Yast.import "LogView"
      Yast.import "SLPAPI"
      Yast.import "NetworkInterfaces"
      Yast.import "NetworkService"
      Yast.import "NtpClient"
      Yast.import "CWMFirewallInterfaces"
      Yast.import "Report"
      Yast.import "Hostname"
      Yast.import "IP"
      Yast.import "Progress"

      Yast.include include_target, "ntp-client/helps.rb"
      Yast.include include_target, "ntp-client/dialogs.rb"

      # selected type of peer
      @peer_type_selected = nil

      # List of NTP servers already found
      @found_servers_cache = nil

      # The 'Current Record' when NTP is being initialized, see bug 177575
      @selected_record_during_init = {}

      # if there was some server defined before pool_ntp_org was selected
      @ntp_server_before_random_servers = ""

      @last_country = nil
    end

### - (`Object`) InitWidgets

Initialize all widgets

Returns:

- a map of widgets

    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    1525
    1526
    1527
    1528
    1529
    1530
    1531
    1532
    1533
    1534
    1535
    1536
    1537
    1538
    1539
    1540
    1541
    1542
    1543
    1544
    1545
    1546
    1547
    1548
    1549
    1550
    1551
    1552
    1553
    1554
    1555
    1556
    1557
    1558
    1559
    1560
    1561
    1562
    1563
    1564
    1565
    1566
    1567
    1568
    1569
    1570
    1571
    1572
    1573
    1574
    1575
    1576
    1577
    1578
    1579
    1580
    1581
    1582
    1583
    1584
    1585
    1586
    1587
    1588
    1589
    1590
    1591
    1592
    1593
    1594
    1595
    1596
    1597
    1598
    1599
    1600
    1601
    1602
    1603
    1604
    1605
    1606
    1607
    1608
    1609
    1610
    1611
    1612
    1613
    1614
    1615
    1616
    1617
    1618
    1619
    1620
    1621
    1622
    1623
    1624
    1625
    1626
    1627
    1628
    1629
    1630
    1631
    1632
    1633
    1634
    1635
    1636
    1637
    1638
    1639
    1640
    1641
    1642
    1643
    1644
    1645
    1646
    1647
    1648
    1649
    1650
    1651
    1652
    1653
    1654
    1655
    1656
    1657
    1658
    1659
    1660
    1661
    1662
    1663
    1664
    1665
    1666
    1667
    1668
    1669
    1670
    1671
    1672
    1673
    1674
    1675
    1676
    1677
    1678
    1679
    1680
    1681
    1682
    1683
    1684
    1685
    1686
    1687
    1688
    1689
    1690
    1691
    1692
    1693
    1694
    1695
    1696
    1697
    1698
    1699
    1700
    1701
    1702
    1703
    1704
    1705
    1706
    1707
    1708
    1709
    1710
    1711
    1712
    1713
    1714
    1715
    1716
    1717
    1718
    1719
    1720
    1721
    1722
    1723
    1724
    1725
    1726
    1727
    1728
    1729
    1730
    1731
    1732
    1733
    1734
    1735
    1736
    1737
    1738
    1739
    1740
    1741
    1742
    1743
    1744
    1745
    1746
    1747
    1748
    1749
    1750
    1751
    1752
    1753
    1754
    1755
    1756
    1757
    1758
    1759
    1760
    1761
    1762
    1763
    1764
    1765
    1766
    1767
    1768
    1769
    1770
    1771
    1772
    1773
    1774
    1775
    1776
    1777
    1778
    1779
    1780
    1781
    1782
    1783
    1784
    1785
    1786
    1787
    1788
    1789
    1790
    1791
    1792
    1793
    1794
    1795
    1796
    1797
    1798
    1799
    1800
    1801
    1802
    1803
    1804
    1805
    1806
    1807
    1808
    1809
    1810
    1811
    1812
    1813
    1814
    1815
    1816
    1817
    1818
    1819
    1820
    1821
    1822
    1823
    1824
    1825
    1826
    1827
    1828
    1829
    1830
    1831
    1832
    1833
    1834
    1835
    1836
    1837
    1838
    1839
    1840
    1841
    1842
    1843
    1844
    # File '../../src/include/ntp-client/widgets.rb', line 1385

    def InitWidgets
      address = {
        "widget" => :textentry,
        # text entry label
        "label"  => _("A&ddress"),
        "init"   => fun_ref(method(:addressInit), "void (string)"),
        "store"  => fun_ref(method(:addressStore), "void (string, map)")
      }

      {
        "complex_button"     => {
          "widget"        => :push_button,
          # push button label
          "label"         => _("Ad&vanced Configuration"),
          "help"          => Ops.get_string(@HELPS, "complex_button", ""),
          "handle_events" => ["complex_button", "never", "boot"],
          "handle"        => fun_ref(
            method(:complexButtonHandle),
            "symbol (string, map)"
          )
        },
        "fudge_button"       => {
          "widget"        => :push_button,
          # push button label
          "label"         => _("&Driver Calibration"),
          "help"          => Ops.get_string(@HELPS, "fudge_button", ""),
          "handle_events" => ["fudge_button"],
          "handle"        => fun_ref(
            method(:fudgeButtonHandle),
            "symbol (string, map)"
          )
        },
        "interval"           => {
          "widget"  => :intfield,
          "label"   => _("&Interval of the Synchronization in Minutes"),
          "minimum" => 1,
          "maximum" => 60,
          "init"    => fun_ref(method(:intervalInit), "void (string)"),
          "store"   => fun_ref(method(:intervalStore), "void (string, map)"),
          "no_help" => true,
          "handle"  => fun_ref(method(:timeSyncOrNo), "symbol (string, map)")
        },
        "start"              => {
          "widget"        => :radio_buttons,
          # frame
          "label"         => _("Start NTP Daemon"),
          "items"         => [
            # radio button
            ["never", _("Only &Manually")],
            # radio button
            ["sync", _("&Synchronize without Daemon")],
            # radio button
            ["boot", _("Now and on &Boot")]
          ],
          "help"          => Ops.get_string(@HELPS, "start", ""),
          "init"          => fun_ref(method(:startInit), "void (string)"),
          "store"         => fun_ref(method(:startStore), "void (string, map)"),
          "handle"        => fun_ref(
            method(:startHandle),
            "symbol (string, map)"
          ),
          "handle_events" => ["boot", "never", "sync"],
          "opt"           => [:notify]
        },
        "run_chroot"         => {
          "widget" => :checkbox,
          # check box
          "label"  => _("Run NTP Daemon in Chroot &Jail"),
          "init"   => fun_ref(method(:chrootInit), "void (string)"),
          "store"  => fun_ref(method(:chrootStore), "void (string, map)"),
          "handle" => fun_ref(
            method(:ntpEnabledOrDisabled),
            "symbol (string, map)"
          ),
          "help"   => Ops.get_string(@HELPS, "chroot_environment", "")
        },
        "secure"             => {
          "widget" => :checkbox,
          #TRANSLATORS:
          "label"  => _(
            "&Restrict NTP Service to Configured Servers Only "
          ),
          "init"   => fun_ref(method(:secureInit), "void (string)"),
          "store"  => fun_ref(method(:secureStore), "void (string, map)"),
          "help"   => Ops.get_string(@HELPS, "secure", "")
        },
        "policy_combo" =>
          # FIXME
          {
            "widget" => :combobox,
            "opt"    => [:notify],
            "items"  => [
              # combo box item FIXME usability
              [:nomodify, _("Manual")],
              # combo box item
              [:auto, _("Auto")],
              # combo box item
              [:custom, _("Custom")]
            ],
            "label"  => _("&Runtime Configuration Policy"),
            "init"   => fun_ref(method(:PolicyInit), "void (string)"),
            "store"  => fun_ref(method(:PolicyStore), "void (string, map)"),
            "handle" => fun_ref(
              method(:ntpEnabledOrDisabled),
              "symbol (string, map)"
            ),
            "help"   => Ops.get_string(@HELPS, "policy_combo", "")
          },
        "custom_policy" =>
          # FIXME
          {
            "widget" => :textentry,
            "label"  => _("&Custom Policy"),
            "handle" => fun_ref(
              method(:ntpEnabledOrDisabled),
              "symbol (string, map)"
            ),
            "help"   => Ops.get_string(@HELPS, "custom_policy", "")
          },
        "use_random_servers" => {
          "widget" => :checkbox,
          "opt"    => [:notify],
          # check box
          "label"  => _("&Use Random Servers from pool.ntp.org"),
          "init"   => fun_ref(method(:RandomServersInit), "void (string)"),
          "store"  => fun_ref(method(:RandomServersStore), "void (string, map)"),
          "handle" => fun_ref(
            method(:RandomServersHandle),
            "symbol (string, map)"
          ),
          "help"   => Ops.get_string(@HELPS, "use_random_servers", "")
        },
        "server_address"     => Builtins.union(
          address,
          {
            # text entry label
            "label"             => _("&Address"),
            "help"              => Ops.get_string(@HELPS, "server_address", ""),
            "handle"            => fun_ref(
              method(:serverAddressHandle),
              "symbol (string, map)"
            ),
            "validate_type"     => :function,
            "validate_function" => fun_ref(
              method(:serverAddressValidate),
              "boolean (string, map)"
            ),
            "widget"            => :custom,
            "custom_widget"     => VBox(
              HBox(
                TextEntry(
                  Id("server_address"),
                  Opt(:hstretch),
                  # text entry
                  _("&Address")
                ),
                VBox(
                  Label(" "),
                  # push button
                  MenuButton(
                    Id(:select_server),
                    _("&Select..."),
                    [
                      Item(Id(:select_local), _("Local NTP Server")),
                      Item(Id(:select_public), _("Public NTP Server"))
                    ]
                  )
                )
              ),
              HBox(
                HStretch(),
                # push button
                PushButton(Id(:test_server), _("&Test")),
                HStretch()
              )
            )
          }
        ),
        "overview"           => {
          "widget"        => :custom,
          "custom_widget" => VBox(
            Table(
              Id(:overview),
              Opt(:notify),
              Header(
                # table header
                _("Synchronization Type"),
                # table header
                _("Address")
              )
            ),
            HBox(
              PushButton(Id(:add), Label.AddButton), # menu button
              #		    `MenuButton (`id (`advanced), _("&Advanced..."), [
              # item of menu button
              #			`item (`id (`display_log), _("Display &Log...")),
              #		    ])
              PushButton(Id(:edit), Label.EditButton),
              PushButton(Id(:delete), Label.DeleteButton),
              HStretch(),
              # push button
              PushButton(Id(:display_log), _("Display &Log..."))
            )
          ),
          "help"          => Ops.get_string(@HELPS, "overview", ""),
          "init"          => fun_ref(method(:overviewInit), "void (string)"),
          "handle"        => fun_ref(
            method(:overviewHandle),
            "symbol (string, map)"
          )
        },
        "paddress"           => Builtins.union(
          address,
          { "help" => Ops.get_string(@HELPS, "paddress", "") }
        ),
        "bcaddress"          => Builtins.union(
          address,
          { "help" => Ops.get_string(@HELPS, "bcaddress", "") }
        ),
        "bccaddress"         => Builtins.union(
          address,
          { "help" => Ops.get_string(@HELPS, "bccaddress", "") }
        ),
        "clock_type"         => {
          "widget" => :combobox,
          # combo box label
          "label"  => _("Clock &Type"),
          "items"  => getClockTypesCombo,
          "help"   => Ops.get_string(@HELPS, "clock_type", ""),
          "opt"    => [:notify],
          "init"   => fun_ref(method(:clockTypeInit), "void (string)"),
          "handle" => fun_ref(method(:clockTypeHandle), "symbol (string, map)"),
          "store"  => fun_ref(method(:clockTypeStore), "void (string, map)")
        },
        "unit_number"        => {
          "widget"  => :intfield,
          # int field
          "label"   => _("Unit &Number"),
          "help"    => Ops.get_string(@HELPS, "unit_number", ""),
          "minimum" => 0,
          "maximum" => 3,
          "init"    => fun_ref(method(:unitNumberInit), "void (string)"),
          "store"   => fun_ref(method(:unitNumberStore), "void (string, map)")
        },
        "create_symlink"     => {
          "widget"        => :checkbox,
          # check box
          "label"         => _("Create &Symlink"),
          "opt"           => [:notify],
          "init"          => fun_ref(
            method(:createSymlinkHandle),
            "symbol (string, map)"
          ),
          "handle_events" => ["create_symlink"],
          "init"          => fun_ref(
            method(:createSymlinkInit),
            "void (string)"
          ),
          "handle"        => fun_ref(
            method(:createSymlinkHandle),
            "symbol (string, map)"
          ),
          "store"         => fun_ref(
            method(:createSymlinkStore),
            "void (string, map)"
          ),
          "no_help"       => true
        },
        "device"             => {
          "widget" => :textentry,
          # text entry
          "label"  => _("&Device"),
          "init"   => fun_ref(method(:deviceInit), "void (string)"),
          "store"  => fun_ref(method(:deviceStore), "void (string, map)"),
          "help"   => Ops.get_string(@HELPS, "device", "")
        },
        "browse"             => {
          "widget"        => :push_button,
          "label"         => Label.BrowseButton,
          "handle_events" => ["browse"],
          "handle"        => fun_ref(
            method(:browseButtonHandle),
            "symbol (string, map)"
          ),
          "no_help"       => true
        },
        "options"            => {
          "widget" => :textentry,
          # text entry label
          "label"  => Label.Options,
          "init"   => fun_ref(method(:optionsInit), "void (string)"),
          "store"  => fun_ref(method(:optionsStore), "void (string, map)"),
          "help"   => Ops.get_string(@HELPS, "options", "")
        },
        "ac_options"         => {
          "widget" => :textentry,
          "label"  => _("Access Control Options"),
          "init"   => fun_ref(method(:restrictOptionsInit), "void (string)"),
          "store"  => fun_ref(
            method(:restrictOptionsStore),
            "void (string, map)"
          ),
          "help"   => Ops.get_string(@HELPS, "restrict", "")
        },
        "peer_types"         => {
          "widget"   => :radio_buttons,
          "items"    => [
            # radio button, NTP relationship type
            ["server", _("&Server")],
            # radio button, NTP relationship type
            ["peer", _("&Peer")],
            # radio button, NTP relationship type
            ["__clock", _("&Radio Clock")],
            # radio button, NTP relationship type
            ["broadcast", _("&Outgoing Broadcast")],
            # radio button, NTP relationship type
            ["broadcastclient", _("&Incoming Broadcast")]
          ],
          # frame
          "label"    => _("Type"),
          "init"     => fun_ref(method(:peerTypesInit), "void (string)"),
          "handle"   => fun_ref(
            method(:peerTypesHandle),
            "symbol (string, map)"
          ),
          "help"     => Ops.get_string(@HELPS, "peer_types", ""),
          "hspacing" => 3,
          "vspacing" => 1
        },
        "servers_source"     => {
          "widget" => :radio_buttons,
          "items"  => [
            # radio button
            ["lookup_rb", _("Loc&al Network")],
            # radio button
            ["list_rb", _("&Public NTP Server")]
          ],
          "opt"    => [:notify],
          "init"   => fun_ref(method(:ServersSourceInit), "void (string)"),
          # frame label
          "label"  => _("NTP Server Location"),
          "help"   => Ops.get_string(@HELPS, "servers_source", "")
        },
        "found_servers"      => {
          "widget"            => :custom,
          "custom_widget"     => HBox(
            HWeight(
              3,
              ReplacePoint(
                Id(:server_address_rp),
                ComboBox(
                  Id("server_address"),
                  Opt(:editable, :hstretch),
                  # combo box label
                  _("&Address"),
                  []
                )
              )
            ),
            HWeight(
              1,
              VBox(
                Label(" "),
                # push button
                PushButton(Id(:lookup_server), _("&Lookup"))
              )
            )
          ),
          "init"              => fun_ref(
            method(:FoundServersInit),
            "void (string)"
          ),
          "handle"            => fun_ref(
            method(:FoundServersHandle),
            "symbol (string, map)"
          ),
          "store"             => fun_ref(
            method(:FoundServersStore),
            "void (string, map)"
          ),
          "validate_type"     => :function,
          "validate_function" => fun_ref(
            method(:FoundServersValidate),
            "boolean (string, map)"
          ),
          "help"              => Ops.get_string(@HELPS, "found_servers", "")
        },
        "servers_list"       => {
          "widget"            => :custom,
          "custom_widget"     => VBox(
            ReplacePoint(
              Id(:country_rp),
              ComboBox(
                Id(:country),
                Opt(:notify, :hstretch),
                # combo box header
                _("&Country"),
                []
              )
            ),
            ReplacePoint(
              Id(:servers_rp),
              ComboBox(
                Id(:servers),
                Opt(:hstretch),
                # selection box header
                _("Public NTP &Servers"),
                []
              )
            )
          ),
          "init"              => fun_ref(
            method(:ServerListInit),
            "void (string)"
          ),
          "handle"            => fun_ref(
            method(:ServerListHandle),
            "symbol (string, map)"
          ),
          "store"             => fun_ref(
            method(:ServerListStore),
            "void (string, map)"
          ),
          "validate_type"     => :function,
          "validate_function" => fun_ref(
            method(:ServerListValidate),
            "boolean (string, map)"
          ),
          "help"              => Ops.get_string(@HELPS, "servers_list", "")
        },
        "select_test_local"  => {
          "widget"        => :push_button,
          # push button
          "label"         => _("&Test"),
          "handle_events" => ["select_test_local"],
          "handle"        => fun_ref(
            method(:LocalSelectTestHandle),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "selected_test", "")
        },
        "select_test_public" => {
          "widget"        => :push_button,
          # push button
          "label"         => _("&Test"),
          "handle_events" => ["select_test_public"],
          "handle"        => fun_ref(
            method(:PublicSelectTestHandle),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "selected_test", "")
        },
        "firewall"           => CWMFirewallInterfaces.CreateOpenFirewallWidget(
          {
            "services"        => NtpClient.firewall_services,
            "display_details" => true
          }
        )
      }
    end

### - (`Object`) intervalInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    111
    112
    113
    114
    115
    # File '../../src/include/ntp-client/widgets.rb', line 111

    def intervalInit(id)
      UI.ChangeWidget(Id("interval"), :Value, NtpClient.sync_interval)

      nil
    end

### - (`Object`) intervalStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

    120
    121
    122
    123
    124
    125
    126
    127
    # File '../../src/include/ntp-client/widgets.rb', line 120

    def intervalStore(id, event)
      event = deep_copy(event)
      NtpClient.sync_interval = Convert.to_integer(
        UI.QueryWidget(Id("interval"), :Value)
      )

      nil
    end

### - (`Object`) LocalSelectTestHandle(id, event)

    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    # File '../../src/include/ntp-client/widgets.rb', line 1353

    def LocalSelectTestHandle(id, event)
      event = deep_copy(event)
      server = ""
      #    if ((boolean)UI::QueryWidget (`id ("lookup_rb"), `Value))
      #    {
      server = Convert.to_string(UI.QueryWidget(Id("server_address"), :Value))
      #    }
      #    else
      #    {
      #	server = (string)UI::QueryWidget (`id (`servers), `Value);
      #    }
      NtpClient.TestNtpServer(server, :result_popup)
      nil
    end

### - (`Symbol`) ntpEnabledOrDisabled(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always nil

    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    # File '../../src/include/ntp-client/widgets.rb', line 83

    def ntpEnabledOrDisabled(id, event)
      event = deep_copy(event)
      ev_id = Ops.get(event, "ID")
      if ev_id == "boot" || ev_id == "never" || ev_id == "sync"
        enabled = UI.QueryWidget(Id("start"), :CurrentButton) != "never"
        UI.ChangeWidget(Id(id), :Enabled, enabled)
      end

      nil
    end

### - (`Object`) optionsInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    # File '../../src/include/ntp-client/widgets.rb', line 834

    def optionsInit(id)
      # bnc#438704, add a recommended option
      UI.ChangeWidget(
        Id("options"),
        :Value,
        Ops.get_string(NtpClient.selected_record, "options", "iburst")
      )

      nil
    end

### - (`Object`) optionsStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    # File '../../src/include/ntp-client/widgets.rb', line 848

    def optionsStore(id, event)
      event = deep_copy(event)
      Ops.set(
        NtpClient.selected_record,
        "options",
        UI.QueryWidget(Id("options"), :Value)
      )

      nil
    end

### - (`Object`) overviewHandle(id, event)

Handle events on the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Object`) —

  event to pass to WS or nil

    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    # File '../../src/include/ntp-client/widgets.rb', line 609

    def overviewHandle(id, event)
      event = deep_copy(event)
      #    ntpEnabledOrDisabled (id, event);
      if Ops.get(event, "ID") == :display_log
        showLogPopup
        return nil
      end
      ev_id = Ops.get(event, "ID")
      if ev_id == "boot" || ev_id == "never" || ev_id == "sync" ||
          ev_id == "policy_combo"
        pol = Convert.to_symbol(UI.QueryWidget(Id("policy_combo"), :Value))

        enabled = UI.QueryWidget(Id("start"), :CurrentButton) != "never"
        #	UI::ChangeWidget (`id (`advanced), `Enabled, enabled);
        enabled = enabled && pol != :nomodify
        UI.ChangeWidget(Id(:add), :Enabled, enabled)
        UI.ChangeWidget(Id(:edit), :Enabled, enabled)
        UI.ChangeWidget(Id(:delete), :Enabled, enabled)
        UI.ChangeWidget(Id(:overview), :Enabled, enabled)

        if enabled && pol == :custom
          UI.ChangeWidget(Id("custom_policy"), :Enabled, true)
          UI.ChangeWidget(Id("custom_policy"), :Value, NtpClient.ntp_policy)
        else
          UI.ChangeWidget(Id("custom_policy"), :Enabled, false)
          UI.ChangeWidget(Id("custom_policy"), :Value, "")
        end
        Builtins.y2milestone(
          "set modified from %1 to true 4.1 id %2 map %3",
          NtpClient.modified,
          id,
          event
        )
        NtpClient.modified = true
        return nil
      end
      types = {
        "server"          => :server,
        "peer"            => :peer,
        "__clock"         => :clock,
        "broadcast"       => :bcast,
        "broadcastclient" => :bcastclient
      }
      if Ops.get(event, "ID") == :add
        NtpClient.selectSyncRecord(-1)
        @peer_type_selected = nil
        Builtins.y2milestone(
          "set modified from %1 to true 4.2 id %2 map %3",
          NtpClient.modified,
          id,
          event
        )
        NtpClient.modified = true
        return :add
      elsif Ops.get(event, "ID") == :edit || Ops.get(event, "ID") == :overview
        NtpClient.selectSyncRecord(
          Convert.to_integer(UI.QueryWidget(Id(:overview), :CurrentItem))
        )
        type = Ops.get_string(NtpClient.selected_record, "type", "")
        Builtins.y2milestone(
          "set modified from %1 to true 4.3 id %2 map %3",
          NtpClient.modified,
          id,
          event
        )
        NtpClient.modified = true
        return Ops.get(types, type)
      elsif Ops.get(event, "ID") == :delete
        # yes-no popup
        if Confirm.DeleteSelected
          NtpClient.deleteSyncRecord(
            Convert.to_integer(UI.QueryWidget(Id(:overview), :CurrentItem))
          )
          overviewRedraw
          @sync_record_modified = true
          Builtins.y2milestone(
            "set modified from %1 to true 4.4 id %2 map %3",
            NtpClient.modified,
            id,
            event
          )
          NtpClient.modified = true
        end
      end
      nil
    end

### - (`Object`) overviewInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    698
    699
    700
    701
    702
    703
    704
    705
    # File '../../src/include/ntp-client/widgets.rb', line 698

    def overviewInit(id)
      tmp = NtpClient.modified
      overviewRedraw
      overviewHandle(id, { "ID" => "boot" })
      NtpClient.modified = tmp

      nil
    end

### - (`Object`) overviewRedraw

Redraw the overview table

    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
    603
    # File '../../src/include/ntp-client/widgets.rb', line 562

    def overviewRedraw
      types = {
        # table cell, NTP relationship type
        "server"          => _("Server"),
        # table cell, NTP relationship type
        "peer"            => _("Peer"),
        # table cell, NTP relationship type
        "broadcast"       => _(
          "Outgoing Broadcast"
        ),
        # table cell, NTP relationship type
        "broadcastclient" => _(
          "Incoming Broadcast"
        )
      }
      items = Builtins.maplist(NtpClient.getSyncRecords) do |i|
        type = Ops.get_string(i, "type", "")
        address = Ops.get_string(i, "address", "")
        index = Ops.get_integer(i, "index", -1)
        if type == "__clock"
          clock_type = getClockType(address)
          unit_number = getClockUnitNumber(address)
          device = Ops.get_string(i, "device", "")
          if device == ""
            # table cell, %1 is integer 0-3
            device = Builtins.sformat(_("Unit Number: %1"), unit_number)
          end
          device = "" if clock_type == 1 && unit_number == 0
          clock_name = Ops.get(@clock_types, [clock_type, "name"], "")
          if clock_name == ""
            # table cell, NTP relationship type
            clock_name = _("Local Radio Clock")
          end
          next Item(Id(index), clock_name, device)
        end
        Item(Id(index), Ops.get_string(types, type, ""), address)
      end
      UI.ChangeWidget(Id(:overview), :Items, items)
      UI.SetFocus(Id(:overview))

      nil
    end

### - (`Symbol`) peerTypesHandle(id, event)

Handle events on the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  event to pass to WS or nil

    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    # File '../../src/include/ntp-client/widgets.rb', line 916

    def peerTypesHandle(id, event)
      event = deep_copy(event)
      @peer_type_selected = Convert.to_string(
        UI.QueryWidget(Id("peer_types"), :CurrentButton)
      )
      types = {
        "server"          => :server,
        "peer"            => :peer,
        "__clock"         => :clock,
        "broadcast"       => :bcast,
        "broadcastclient" => :bcastclient
      }
      if Ops.get(event, "ID") == :next
        Ops.set(NtpClient.selected_record, "type", @peer_type_selected)
        return Ops.get(types, @peer_type_selected)
      end
      nil
    end

### - (`Object`) peerTypesInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    902
    903
    904
    905
    906
    907
    908
    909
    910
    # File '../../src/include/ntp-client/widgets.rb', line 902

    def peerTypesInit(id)
      if @peer_type_selected != nil
        UI.ChangeWidget(Id("peer_types"), :CurrentButton, @peer_type_selected)
      else
        UI.ChangeWidget(Id("peer_types"), :CurrentButton, "server")
      end

      nil
    end

### - (`Object`) PolicyInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    # File '../../src/include/ntp-client/widgets.rb', line 425

    def PolicyInit(id)
      if NtpClient.PolicyIsNomodify
        UI.ChangeWidget(Id("policy_combo"), :Value, Id(:nomodify))
        UI.ChangeWidget(Id("custom_policy"), :Value, "")
        UI.ChangeWidget(Id("custom_policy"), :Enabled, false)
      elsif NtpClient.PolicyIsAuto
        UI.ChangeWidget(Id("policy_combo"), :Value, Id(:auto))
        UI.ChangeWidget(Id("custom_policy"), :Value, "")
        UI.ChangeWidget(Id("custom_policy"), :Enabled, false)
      else
        UI.ChangeWidget(Id("policy_combo"), :Value, Id(:custom))
        UI.ChangeWidget(Id("custom_policy"), :Value, NtpClient.ntp_policy)
        UI.ChangeWidget(Id("custom_policy"), :Enabled, true)
      end

      nil
    end

### - (`Object`) PolicyStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    # File '../../src/include/ntp-client/widgets.rb', line 446

    def PolicyStore(id, event)
      event = deep_copy(event)
      tmp = NtpClient.ntp_policy
      if UI.QueryWidget(Id("policy_combo"), :Value) == :nomodify
        NtpClient.ntp_policy = ""
      elsif UI.QueryWidget(Id("policy_combo"), :Value) == :auto
        NtpClient.ntp_policy = "auto"
      else
        NtpClient.ntp_policy = Convert.to_string(
          UI.QueryWidget(Id("custom_policy"), :Value)
        )
      end
      if tmp != NtpClient.ntp_policy
        Builtins.y2milestone("set modified to true 3")
        NtpClient.modified = true
      end

      nil
    end

### - (`Object`) PublicSelectTestHandle(id, event)

    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    # File '../../src/include/ntp-client/widgets.rb', line 1368

    def PublicSelectTestHandle(id, event)
      event = deep_copy(event)
      server = ""
      #    if ((boolean)UI::QueryWidget (`id ("lookup_rb"), `Value))
      #    {
      #	server = (string)UI::QueryWidget (`id ("server_address"), `Value);
      #    }
      #    else
      #    {
      server = Convert.to_string(UI.QueryWidget(Id(:servers), :Value))
      #    }
      NtpClient.TestNtpServer(server, :result_popup)
      nil
    end

### - (`Object`) RandomServersHandle(id, event)

Function handles the “use_random_servers” checkbox

    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    # File '../../src/include/ntp-client/widgets.rb', line 508

    def RandomServersHandle(id, event)
      event = deep_copy(event)
      ntpEnabledOrDisabled(id, event)
      # do not handle anything when called by pressing the checkbox
      return nil if id != "use_random_servers"
      return nil if Ops.get_string(event, "EventReason", "") != "ValueChanged"
      if Ops.get_string(event, "WidgetID", "") != "use_random_servers"
        return nil
      end

      Builtins.y2milestone("Handling random_servers")
      use_random_servers = Convert.to_boolean(
        UI.QueryWidget(Id("use_random_servers"), :Value)
      )
      # If random servers are selected, user is not allowed to enter his/her own NTP server
      if use_random_servers
        Builtins.y2milestone("Activating random servers")
        @ntp_server_before_random_servers = Convert.to_string(
          UI.QueryWidget(Id("server_address"), :Value)
        )
        # if there is already some server defined
        if @ntp_server_before_random_servers != ""
          if !Popup.ContinueCancel(
              _(
                "Enabling Random Servers from pool.ntp.org would\n" +
                  "replace the current NTP server.\n" +
                  "\n" +
                  "Really replace the current NTP server?"
              )
            )
            # user has cancelled the operation, return it back
            UI.ChangeWidget(Id("use_random_servers"), :Value, false)
            return nil
          end
        end

        UI.ChangeWidget(Id("server_address"), :Enabled, false)
        UI.ChangeWidget(Id(:select_server), :Enabled, false)
        UI.ChangeWidget(Id("server_address"), :Value, "")
      else
        Builtins.y2milestone("Deactivating random servers")
        UI.ChangeWidget(Id("server_address"), :Enabled, true)
        UI.ChangeWidget(Id(:select_server), :Enabled, true)
        UI.ChangeWidget(
          Id("server_address"),
          :Value,
          @ntp_server_before_random_servers
        )
      end

      nil
    end

### - (`Object`) RandomServersInit(id)

    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    # File '../../src/include/ntp-client/widgets.rb', line 467

    def RandomServersInit(id)
      ntpEnabledOrDisabled(id, {})
      return nil if id != "use_random_servers"
      Builtins.y2milestone("Initializing random servers")

      rnd_servers = NtpClient.IsRandomServersServiceEnabled
      if rnd_servers
        # Random servers function is enabled
        UI.ChangeWidget(Id("use_random_servers"), :Value, true)
        UI.ChangeWidget(Id("server_address"), :Enabled, false)
        UI.ChangeWidget(Id(:select_server), :Enabled, false)
        UI.ChangeWidget(Id("server_address"), :Value, "")
      else
        # Random servers function is disabled
        UI.ChangeWidget(Id("use_random_servers"), :Value, false)
        if NtpClient.run_service || NtpClient.synchronize_time
          UI.ChangeWidget(Id("server_address"), :Enabled, true)
          UI.ChangeWidget(Id(:select_server), :Enabled, true)
        else
          UI.ChangeWidget(Id("server_address"), :Enabled, false)
          UI.ChangeWidget(Id(:select_server), :Enabled, false)
        end
      end

      nil
    end

### - (`Object`) RandomServersStore(id, event)

    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    # File '../../src/include/ntp-client/widgets.rb', line 494

    def RandomServersStore(id, event)
      event = deep_copy(event)
      return nil if id != "use_random_servers"

      if Convert.to_boolean(UI.QueryWidget(Id("use_random_servers"), :Value))
        NtpClient.ActivateRandomPoolServersFunction
      else
        NtpClient.DeActivateRandomPoolServersFunction
      end

      nil
    end

### - (`Object`) restrictOptionsInit(id)

    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    # File '../../src/include/ntp-client/widgets.rb', line 859

    def restrictOptionsInit(id)
      address = Ops.get_string(NtpClient.selected_record, "address", "")
      if NtpClient.restrict_map == {} || NtpClient.PolicyIsNonstatic
        UI.ChangeWidget(Id("ac_options"), :Enabled, false)
      else
        if Builtins.haskey(NtpClient.restrict_map, address)
          UI.ChangeWidget(
            Id("ac_options"),
            :Value,
            Ops.get_string(NtpClient.restrict_map, [address, "options"], "")
          )
        else
          UI.ChangeWidget(Id("ac_options"), :Value, "notrap nomodify noquery")
        end
      end

      nil
    end

### - (`Object`) restrictOptionsStore(id, event)

    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    # File '../../src/include/ntp-client/widgets.rb', line 878

    def restrictOptionsStore(id, event)
      event = deep_copy(event)
      address = Ops.get_string(NtpClient.selected_record, "address", "")
      opts = Convert.to_string(UI.QueryWidget(Id("ac_options"), :Value))

      return if address == ""
      if NtpClient.PolicyIsNonstatic
        NtpClient.restrict_map = {}
        return
      end
      if Builtins.haskey(NtpClient.restrict_map, address)
        Ops.set(NtpClient.restrict_map, [address, "options"], opts)
      else
        Ops.set(
          NtpClient.restrict_map,
          address,
          { "comment" => "", "mask" => "", "options" => opts }
        )
      end

      nil
    end

### - (`Object`) secureInit(id)

    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    # File '../../src/include/ntp-client/widgets.rb', line 373

    def secureInit(id)
      Builtins.y2milestone("Restrict %1", NtpClient.restrict_map)
      if NtpClient.PolicyIsNonstatic
        UI.ChangeWidget(Id("secure"), :Enabled, false)
      else
        UI.ChangeWidget(Id("secure"), :Value, NtpClient.restrict_map != {})
      end

      nil
    end

### - (`Object`) secureStore(id, event)

    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    # File '../../src/include/ntp-client/widgets.rb', line 384

    def secureStore(id, event)
      event = deep_copy(event)
      restrict = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))

      if restrict
        servers = NtpClient.GetUsedNtpServers

        if NtpClient.restrict_map == {}
          Ops.set(
            NtpClient.restrict_map,
            "default",
            { "mask" => "", "comment" => "", "options" => "ignore" }
          )

          Ops.set(
            NtpClient.restrict_map,
            "127.0.0.1",
            { "mask" => "", "comment" => "", "options" => "" }
          )

          Builtins.foreach(servers) do |s|
            Ops.set(
              NtpClient.restrict_map,
              s,
              {
                "mask"    => "",
                "comment" => "",
                "options" => "nomodify notrap noquery"
              }
            )
          end
        end
      else
        NtpClient.restrict_map = {}
      end

      nil
    end

### - (`Symbol`) serverAddressHandle(id, event)

Handle events on the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  event to pass to WS or nil

    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    # File '../../src/include/ntp-client/widgets.rb', line 789

    def serverAddressHandle(id, event)
      event = deep_copy(event)
      ev_id = Ops.get(event, "ID")
      server = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      if ev_id == "boot" || ev_id == "never"
        enabled = UI.QueryWidget(Id("start"), :CurrentButton) != "never"
        # checkbox selected - random servers feature
        if UI.QueryWidget(Id("use_random_servers"), :Value) == true
          UI.ChangeWidget(Id(id), :Enabled, false)
          UI.ChangeWidget(Id(:select_server), :Enabled, false)
        else
          UI.ChangeWidget(Id(id), :Enabled, enabled)
          UI.ChangeWidget(Id(:select_server), :Enabled, enabled)
        end
        UI.ChangeWidget(Id(:test_server), :Enabled, enabled)

        return nil
      end
      if ev_id == :test_server
        if UI.WidgetExists(Id("use_random_servers")) &&
            Convert.to_boolean(UI.QueryWidget(Id("use_random_servers"), :Value))
          NtpClient.TestNtpServer(
            Ops.get(
              NtpClient.random_pool_servers,
              Builtins.random(4),
              "0.pool.ntp.org"
            ),
            :result_popup
          )
        else
          if serverAddressValidate("server_address", {})
            NtpClient.TestNtpServer(server, :result_popup)
          end
        end
      elsif ev_id == :select_local
        return :select_local
      elsif ev_id == :select_public
        return :select_public
      end

      nil
    end

### - (`Object`) ServerAddressIsInConfiguration

Check the current confifuration and returns whether some server address is defined

    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    # File '../../src/include/ntp-client/widgets.rb', line 253

    def ServerAddressIsInConfiguration
      ret = false
      rss = NtpClient.IsRandomServersServiceEnabled

      Builtins.foreach(NtpClient.ntp_records) do |one_record|
        # checking for server
        if Ops.get(one_record, "type") == "server"
          # RandomServersService is disabled
          if !rss
            ret = true
            raise Break
            # RandomServersService is enabled, don't take servers from RSS
          elsif !Builtins.contains(
              NtpClient.random_pool_servers,
              Ops.get_string(one_record, "address", "")
            )
            ret = true
            raise Break
          end
        end
      end

      ret
    end

### - (`Boolean`) serverAddressValidate(id, event)

Handle events on the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Boolean`) —

  is successful

    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    # File '../../src/include/ntp-client/widgets.rb', line 767

    def serverAddressValidate(id, event)
      event = deep_copy(event)
      # NTP Client is disabled, do not check the server name
      if Ops.get(event, "ID") == :next && UI.WidgetExists(Id("start")) &&
          Convert.to_string(UI.QueryWidget(Id("start"), :CurrentButton)) == "never"
        return true
      end
      # do not check the server IP/Host when changing dialog to "Select"
      #   or when switching to the advanced configuration
      if Ops.get(event, "ID") == :select_local ||
          Ops.get(event, "ID") == :select_public ||
          Ops.get(event, "ID") == :complex
        return true
      end

      CheckCurrentSimpleConfiguration(true)
    end

### - (`Symbol`) ServerListHandle(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always nil

    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    # File '../../src/include/ntp-client/widgets.rb', line 1102

    def ServerListHandle(id, event)
      event = deep_copy(event)
      #    if (event["ID"]:nil == "list_rb" || event["ID"]:nil == "lookup_rb")
      #    {
      #	boolean enabled = (boolean)UI::QueryWidget (`id ("list_rb"), `Value);
      #	UI::ChangeWidget (`id (`country), `Enabled, enabled);
      #	UI::ChangeWidget (`id (`servers), `Enabled, enabled);
      #	return nil;
      #    }
      country = Convert.to_string(UI.QueryWidget(Id(:country), :Value))
      country = "" if country == nil
      Builtins.y2milestone(
        "Handling server list change, last country: %1, current country: %2",
        @last_country,
        country
      )
      if country != @last_country
        @last_country = country

        items = NtpClient.GetNtpServersByCountry(country, false)
        UI.ReplaceWidget(
          :servers_rp,
          VBox(
            # Combobox has at least 40 characters
            # bug #97184
            HSpacing(40),
            ComboBox(
              Id(:servers),
              Opt(:hstretch),
              # selection box header
              _("Public NTP &Servers"),
              items
            )
          )
        )
        return nil
      end
      if Ops.get(event, "ID") == :test || Ops.get(event, "ID") == :info
        server = Convert.to_string(UI.QueryWidget(Id(:servers), :Value))
        if server == nil || server == ""
          # message report (no server selected)
          Report.Message(_("Select an NTP server."))
          return nil
        end
        if Ops.get(event, "ID") == :test
          NtpClient.TestNtpServer(server, :result_popup)
        end
        return nil
      end
      nil
    end

### - (`Object`) ServerListInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    # File '../../src/include/ntp-client/widgets.rb', line 1156

    def ServerListInit(id)
      country_names = NtpClient.GetCountryNames
      country_codes = Builtins.mapmap(country_names) { |k, v| { v => k } }
      country_name_list = Builtins.maplist(country_codes) { |k, v| k }
      country_name_list = Builtins.lsort(country_name_list)
      countries_lst = Builtins.toset(Builtins.maplist(NtpClient.GetNtpServers) do |s, m|
        country = Ops.get(m, "country", "")
        label = Ops.get(country_names, country, country)
        label
      end)
      countries_lst = Builtins.lsort(countries_lst)
      countries = Builtins.maplist(countries_lst) do |label|
        code = Ops.get(country_codes, label, label)
        Item(Id(code), label)
      end
      # combo box item
      countries = Builtins.prepend(countries, Item(Id(""), _("All Countries")))
      UI.ReplaceWidget(
        :country_rp,
        ComboBox(
          Id(:country),
          Opt(:notify, :hstretch),
          # combo box header
          _("&Country"),
          countries
        )
      )
      @last_country = nil

      lang = NtpClient.GetCurrentLanguageCode
      if lang != nil
        Builtins.y2milestone("Current language: %1", lang)
        UI.ChangeWidget(Id(:country), :Value, lang)
      end
      ServerListHandle(id, {})
      ServerListHandle(id, { "ID" => "list_rb" })

      nil
    end

### - (`Object`) ServerListStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    # File '../../src/include/ntp-client/widgets.rb', line 1199

    def ServerListStore(id, event)
      event = deep_copy(event)
      if UI.WidgetExists(Id("list_rb")) &&
          !Convert.to_boolean(UI.QueryWidget(Id("list_rb"), :Value))
        return
      end
      address = Convert.to_string(UI.QueryWidget(Id(:servers), :Value))
      Ops.set(NtpClient.selected_record, "address", address)
      #Do not forget to add type of the record - here we have 'server' (#216456)
      Ops.set(NtpClient.selected_record, "type", "server")

      nil
    end

### - (`Boolean`) ServerListValidate(id, event)

Validation function of a widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused validation

Returns:

- (`Boolean`) —

  true if validation succeeded

    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    # File '../../src/include/ntp-client/widgets.rb', line 1217

    def ServerListValidate(id, event)
      event = deep_copy(event)
      if UI.WidgetExists(Id("list_rb")) &&
          !Convert.to_boolean(UI.QueryWidget(Id("list_rb"), :Value))
        return true
      end
      address = Convert.to_string(UI.QueryWidget(Id(:servers), :Value))
      if address == "" || address == nil
        # report message
        Report.Message(_("Select an NTP server."))
        return false
      end
      true
    end

### - (`Object`) ServersSourceInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    1234
    1235
    1236
    1237
    1238
    # File '../../src/include/ntp-client/widgets.rb', line 1234

    def ServersSourceInit(id)
      UI.ChangeWidget(Id(id), :CurrentButton, "lookup_rb")

      nil
    end

### - (`Object`) showLogPopup

Show popup with NTP daemon's log

    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    # File '../../src/include/ntp-client/widgets.rb', line 57

    def showLogPopup
      LogView.Display(
        {
          "file"    => "/var/log/ntp",
          "save"    => true,
          "actions" => [
            # menubutton entry, try to keep short
            [
              _("Restart NTP Daemon"),
              fun_ref(method(:restartNtpDaemon), "void ()")
            ],
            # menubutton entry, try to keep short
            [
              _("Save Settings and Restart NTP Daemon"),
              fun_ref(method(:SilentWrite), "boolean ()")
            ]
          ]
        }
      )
      nil
    end

### - (`Object`) SilentWrite

Save the configuration and restart NTP deamon

    49
    50
    51
    52
    53
    54
    # File '../../src/include/ntp-client/widgets.rb', line 49

    def SilentWrite
      orig_progress = Progress.set(false)
      ret = NtpClient.Write
      Progress.set(orig_progress)
      ret
    end

### - (`Object`) startHandle(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Object`) —

  always nil

    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
    # File '../../src/include/ntp-client/widgets.rb', line 158

    def startHandle(id, event)
      event = deep_copy(event)
      start = UI.QueryWidget(Id("start"), :CurrentButton) == "boot"
      #All these network devices are possibly started on boot || managed by NM
      #hence do not display the message
      d1 = NetworkInterfaces.Locate("STARTMODE", "onboot")
      d2 = NetworkInterfaces.Locate("STARTMODE", "auto")
      d3 = NetworkInterfaces.Locate("STARTMODE", "nfsroot")
      d4 = NetworkInterfaces.Locate("STARTMODE", "managed")

      devices = Convert.convert(
        Builtins.union(Builtins.union(d1, d2), Builtins.union(d3, d4)),
        :from => "list",
        :to   => "list <string>"
      )
      devices = Builtins.filter(devices) { |d| d != "lo" }
      #Do not display this warning if we use NetworkManager (#299666)
      if start && !NetworkService.IsManaged && Builtins.size(devices) == 0 &&
          Ops.get_string(event, "EventReason", "") != "" &&
          !# continue-cancel popup
          Popup.ContinueCancel(
            _(
              "Warning!\n" +
                "\n" +
                "If you do not have a permanent Internet connection,\n" +
                "starting the NTP daemon can take a very long time and \n" +
                "the daemon might not run properly."
            )
          )
        UI.ChangeWidget(Id("start"), :CurrentButton, "never")
      end

      if start != NtpClient.run_service
        Builtins.y2milestone(
          "set modified from %1 to true 1",
          NtpClient.modified
        )
        NtpClient.modified = true
      end

      if start
        CWMFirewallInterfaces.EnableOpenFirewallWidget
      else
        CWMFirewallInterfaces.DisableOpenFirewallWidget
      end

      if CWMFirewallInterfaces.OpenFirewallModified("firewall")
        NtpClient.change_firewall = true
      end

      nil
    end

### - (`Object`) startInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  any widget id

    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    # File '../../src/include/ntp-client/widgets.rb', line 131

    def startInit(id)
      if NtpClient.synchronize_time
        UI.ChangeWidget(Id("start"), :CurrentButton, "sync")
      elsif NtpClient.run_service
        UI.ChangeWidget(Id("start"), :CurrentButton, "boot")
      else
        UI.ChangeWidget(Id("start"), :CurrentButton, "never")
      end

      nil
    end

### - (`Object`) startStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  any widget id

- event (`Hash`) —

  map event that caused storing process

    146
    147
    148
    149
    150
    151
    152
    # File '../../src/include/ntp-client/widgets.rb', line 146

    def startStore(id, event)
      event = deep_copy(event)
      NtpClient.run_service = UI.QueryWidget(Id("start"), :CurrentButton) == "boot"
      NtpClient.synchronize_time = UI.QueryWidget(Id("start"), :CurrentButton) == "sync"

      nil
    end

### - (`Symbol`) timeSyncOrNo(id, event)

Handle function of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

Returns:

- (`Symbol`) —

  always nil

    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    # File '../../src/include/ntp-client/widgets.rb', line 98

    def timeSyncOrNo(id, event)
      event = deep_copy(event)
      ev_id = Ops.get(event, "ID")
      if ev_id == "boot" || ev_id == "never" || ev_id == "sync"
        enabled = UI.QueryWidget(Id("start"), :CurrentButton) == "sync"
        UI.ChangeWidget(Id(id), :Enabled, enabled)
      end

      nil
    end

### - (`Object`) unitNumberInit(id)

Initialize the widget

Parameters:

- id (`String`) —

  string widget id

    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    # File '../../src/include/ntp-client/widgets.rb', line 1029

    def unitNumberInit(id)
      UI.ChangeWidget(
        Id(id),
        :Value,
        getClockUnitNumber(
          Ops.get_string(NtpClient.selected_record, "address", "")
        )
      )

      nil
    end

### - (`Object`) unitNumberStore(id, event)

Store settings of the widget

Parameters:

- id (`String`) —

  string widget id

- event (`Hash`) —

  map event that caused storing process

    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    # File '../../src/include/ntp-client/widgets.rb', line 1044

    def unitNumberStore(id, event)
      event = deep_copy(event)
      Ops.set(
        NtpClient.selected_record,
        "address",
        setClockUnitNumber(
          Ops.get_string(NtpClient.selected_record, "address", ""),
          Convert.to_integer(UI.QueryWidget(Id(id), :Value))
        )
      )

      nil
    end