Module: Yast::DhcpServerWidgetsInclude

Defined in:
../../src/include/dhcp-server/widgets.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) AllSettingsButtonHandle(key, event)



914
915
916
917
# File '../../src/include/dhcp-server/widgets.rb', line 914

def AllSettingsButtonHandle(key, event)
  event = deep_copy(event)
  :main
end

- (Symbol) chrootHandle(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



260
261
262
263
264
265
266
267
268
269
270
# File '../../src/include/dhcp-server/widgets.rb', line 260

def chrootHandle(id, event)
  event = deep_copy(event)
  if Ops.get(event, "ID") == "start"
    en = Convert.to_boolean(UI.QueryWidget(Id("start"), :Value))
    UI.ChangeWidget(Id(id), :Enabled, en)
    return nil
  end
  start = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
  DhcpServer.SetModified if start != DhcpServer.GetChrootJail
  nil
end

- (Object) chrootInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



237
238
239
240
241
242
243
# File '../../src/include/dhcp-server/widgets.rb', line 237

def chrootInit(id)
  ss = DhcpServer.GetChrootJail
  UI.ChangeWidget(Id(id), :Value, ss)
  chrootHandle(id, { "ID" => "start" })

  nil
end

- (Object) chrootStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



248
249
250
251
252
253
254
# File '../../src/include/dhcp-server/widgets.rb', line 248

def chrootStore(id, event)
  event = deep_copy(event)
  ss = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
  DhcpServer.SetChrootJail(ss)

  nil
end

- (Boolean) commonTableEntryDelete(opt_id, key)

Function for deleting entry from section Used for all (global, host, subnet) section due to the same location of data

Parameters:

  • opt_id (Object)

    any option id

  • key (String)

    string option key

Returns:

  • (Boolean)

    true if was really deleted



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File '../../src/include/dhcp-server/widgets.rb', line 37

def commonTableEntryDelete(opt_id, key)
  opt_id = deep_copy(opt_id)
  return false if !Ops.is_string?(opt_id)
  index = Builtins.tointeger(
    Builtins.regexpsub(
      Convert.to_string(opt_id),
      "^[a-z]+ ([0-9]+)$",
      "\\1"
    )
  )
  if Builtins.substring(key, 0, 7) == "option "
    Ops.set(@current_entry_options, index, nil)
    @current_entry_options = Builtins.filter(@current_entry_options) do |o|
      o != nil
    end
  else
    Ops.set(@current_entry_directives, index, nil)
    @current_entry_directives = Builtins.filter(@current_entry_directives) do |d|
      d != nil
    end
  end
  true
end

- (Object) ConfigSummaryInit(key)



901
902
903
904
905
906
907
908
909
910
911
912
# File '../../src/include/dhcp-server/widgets.rb', line 901

def ConfigSummaryInit(key)
  UI.ChangeWidget(
    Id(key),
    :Value,
    Builtins.sformat(
      "<ul><li>%1</li></ul>",
      Builtins.mergestring(DhcpServer.Summary(["no_start"]), "</li>\n<li>")
    )
  )

  nil
end

- (Symbol) configTreeHandle(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



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
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
# File '../../src/include/dhcp-server/widgets.rb', line 417

def configTreeHandle(id, event)
  event = deep_copy(event)
  if Mode.config &&
      (Ops.get(event, "ID") == :log || Ops.get(event, "ID") == :interfaces ||
        Ops.get(event, "ID") == :tsig_keys)
    # popup message
    Popup.Message(
      _(
        "This function is not available during\npreparation for autoinstallation."
      )
    )
    return nil
  end
  enabled = Convert.to_boolean(UI.QueryWidget(Id("start"), :Value))
  if Ops.get(event, "ID") == "start"
    UI.ChangeWidget(Id("configtree"), :Enabled, enabled)
    UI.ChangeWidget(Id(:adv), :Enabled, enabled)
    UI.ChangeWidget(Id(:edit), :Enabled, enabled)
  end
  if Ops.get(event, "ID") == :log
    LogView.Display(
      {
        "file"    => "/var/log/messages",
        "grep"    => "dhcpd",
        "save"    => true,
        "actions" => [
          # menubutton entry, try to keep short
          [
            _("Restart DHCP Server"),
            fun_ref(method(:RestartDhcpDaemon), "void ()")
          ],
          # menubutton entry, try to keep short
          [
            _("Save Settings and Restart DHCP Server"),
            fun_ref(DhcpServer.method(:Write), "boolean ()")
          ]
        ]
      }
    )
    return nil
  end
  return :interfaces if Ops.get(event, "ID") == :interfaces
  return :tsig_keys if Ops.get(event, "ID") == :tsig_keys
  current_item = Convert.to_string(
    UI.QueryWidget(Id("configtree"), :CurrentItem)
  )
  if current_item == " " || !enabled
    UI.ChangeWidget(Id(:delete), :Enabled, false) 
    #	UI::ChangeWidget (`id (`move), `Enabled, false);
  else
    UI.ChangeWidget(Id(:delete), :Enabled, true) 
    #	UI::ChangeWidget (`id (`move), `Enabled, true);
  end
  selected = key2typeid(current_item)
  if selected == nil
    Builtins.y2error("Unexistent entry selected")
    return nil
  end
  sel_type = Ops.get(selected, "type", "")
  if sel_type == "pool" || sel_type == "class" || sel_type == "host" ||
      !enabled
    UI.ChangeWidget(Id(:add), :Enabled, false)
  else
    UI.ChangeWidget(Id(:add), :Enabled, true)
  end

  if Ops.get(event, "ID") == "configtree" &&
      Ops.get(event, "EventReason") == "Activated"
    Ops.set(event, "ID", :edit)
  end

  if Ops.get(event, "ID") == :add
    @original_entry_type = ""
    @original_entry_id = ""
    @parent_type = Ops.get(selected, "type", "")
    @parent_id = Ops.get(selected, "id", "")
    @current_entry_options = []
    @current_entry_directives = []
    @current_entry_type = ""
    @current_entry_id = ""
    @current_operation = :add
    return :add
  elsif Ops.get(event, "ID") == :edit
    @current_entry_type = Ops.get(selected, "type", "")
    @current_entry_id = Ops.get(selected, "id", "")
    @current_entry_options = DhcpServer.GetEntryOptions(
      @current_entry_type,
      @current_entry_id
    )
    @current_entry_directives = DhcpServer.GetEntryDirectives(
      @current_entry_type,
      @current_entry_id
    )

    @original_entry_type = @current_entry_type
    @original_entry_id = @current_entry_id
    @parent_type = ""
    @parent_id = ""
    @current_operation = :edit

    return :edit
  elsif Ops.get(event, "ID") == :delete
    DhcpServer.DeleteEntry(
      Ops.get(selected, "type", ""),
      Ops.get(selected, "id", "")
    )
    configTreeInit(id)
  elsif Ops.get(event, "ID") == :move
    return nil 
    # TODO move button
  end
  # if (event["ID"]:nil == `add || event["ID"]:nil == `edit)
  #     {
  # 	current_ddns_key_file = DhcpServer::GetDDNSFileName ();
  # 	current_ddns_key_create = DhcpServer::GetDDNSFileCreate ();
  #     }

  nil
end

- (Object) configTreeInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File '../../src/include/dhcp-server/widgets.rb', line 539

def configTreeInit(id)
  items = getItems("", "")
  items = [Item(Id(" "), _("Global Options"), true, items)]
  UI.ReplaceWidget(
    :configtree_rp,
    Tree(
      Id("configtree"),
      Opt(:immediate),
      # tree widget
      _("&Configured Declarations"),
      items
    )
  )
  UI.ChangeWidget(Id("configtree"), :CurrentItem, " ")
  configTreeHandle(id, { "ID" => "start" })
  nil
end

- (Object) confirmAbort

Ask for exit without saving

Returns:

  • event that should be handled, nil if user canceled the exit



171
172
173
174
175
176
177
178
# File '../../src/include/dhcp-server/widgets.rb', line 171

def confirmAbort
  Popup.YesNo(
    # Yes-No popup
    _(
      "If you leave the DHCP server configuration without saving,\nall changes will be lost. Really leave?"
    )
  )
end

- (Object) confirmAbortIfChanged

Check whether settings were changed and if yes, ask for exit without saving

Returns:

  • event that should be handled, nil if user canceled the exit



183
184
185
186
# File '../../src/include/dhcp-server/widgets.rb', line 183

def confirmAbortIfChanged
  return true if !DhcpServer.GetModified
  confirmAbort
end

- (Symbol) DDNSZonesHandle(id, event)

Handle events of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that is handled

Returns:

  • (Symbol)

    for WS



667
668
669
670
671
672
673
674
675
676
677
678
# File '../../src/include/dhcp-server/widgets.rb', line 667

def DDNSZonesHandle(id, event)
  event = deep_copy(event)
  enabled = Convert.to_boolean(UI.QueryWidget(Id("ddns_enable"), :Value))
  UI.ChangeWidget(Id("zone"), :Enabled, enabled)
  UI.ChangeWidget(Id("zone_ip"), :Enabled, enabled)
  UI.ChangeWidget(Id("reverse_zone"), :Enabled, enabled)
  UI.ChangeWidget(Id("reverse_ip"), :Enabled, enabled)
  UI.ChangeWidget(Id("ddns_key"), :Enabled, enabled)
  UI.ChangeWidget(Id("ddns_rev_key"), :Enabled, enabled)
  UI.ChangeWidget(Id(:update_ddns_glob), :Enabled, enabled)
  nil
end

- (Object) DDNSZonesInit(id)

Initialize the widget

Parameters:

  • id (String)

    string widget id



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
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
762
763
764
# File '../../src/include/dhcp-server/widgets.rb', line 682

def DDNSZonesInit(id)
  zone = ""
  ip = ""
  rev_zone = ""
  rev_ip = ""
  key = ""
  rev_key = ""
  UI.ChangeWidget(Id("zone"), :ValidChars, Hostname.ValidCharsDomain)
  UI.ChangeWidget(Id("zone_ip"), :ValidChars, Hostname.ValidCharsDomain)
  UI.ChangeWidget(
    Id("reverse_zone"),
    :ValidChars,
    Hostname.ValidCharsDomain
  )
  UI.ChangeWidget(Id("reverse_ip"), :ValidChars, Hostname.ValidCharsDomain)
  found_ddns = false
  Builtins.foreach(@current_entry_directives) do |d|
    if Ops.get_string(d, "key", "") == "zone"
      value = Ops.get_string(d, "value", "")
      l = Builtins.regexptokenize(
        value,
        "^[ \t]*([^ \t]+)[ \t]*\\{[ \t]*primary[ \t]+([^ \t]+)[ \t]*;[ \t]*key[ \t]+([^ \t]+)[ \t]*;[ \t]*}[ \t]*$"
      )
      if Builtins.size(l) == 3
        z = Ops.get(l, 0, "")
        a = Ops.get(l, 1, "")
        k = Ops.get(l, 2, "")
        if Builtins.issubstring(z, "in-addr.arpa")
          rev_zone = z
          rev_ip = a
          rev_key = k
        else
          zone = z
          ip = a
          key = k
        end
        found_ddns = true
      end
    end
  end

  updater_keys_m = DhcpServer.ListTSIGKeys
  updater_keys = Builtins.maplist(updater_keys_m) do |m|
    Ops.get_string(m, "key", "")
  end

  UI.ReplaceWidget(
    :ddns_key_rp,
    ComboBox(
      Id("ddns_key"),
      # combo box
      _("Forward Zone TSIG &Key"),
      updater_keys
    )
  )
  UI.ReplaceWidget(
    :rev_ddns_key_rp,
    ComboBox(
      Id("ddns_rev_key"),
      # combo box
      _("Reverse Zone TSIG &Key"),
      updater_keys
    )
  )

  if found_ddns
    UI.ChangeWidget(Id("zone"), :Value, zone)
    UI.ChangeWidget(Id("zone_ip"), :Value, ip)
    UI.ChangeWidget(Id("reverse_zone"), :Value, rev_zone)
    UI.ChangeWidget(Id("reverse_ip"), :Value, rev_ip)
    UI.ChangeWidget(Id("ddns_key"), :Value, key)
    UI.ChangeWidget(Id("ddns_rev_key"), :Value, rev_key)
  end
  UI.ChangeWidget(
    Id(:update_ddns_glob),
    :Value,
    DhcpServer.GetAdaptDdnsSettings
  )
  UI.ChangeWidget(Id("ddns_enable"), :Value, found_ddns)
  DDNSZonesHandle(id, {})

  nil
end

- (Object) DDNSZonesStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



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
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
# File '../../src/include/dhcp-server/widgets.rb', line 797

def DDNSZonesStore(id, event)
  event = deep_copy(event)
  @current_entry_directives = Builtins.filter(@current_entry_directives) do |m|
    Ops.get(m, "key", "") != "zone"
  end
  if Convert.to_boolean(UI.QueryWidget(Id("ddns_enable"), :Value))
    zone = Convert.to_string(UI.QueryWidget(Id("zone"), :Value))
    ip = Convert.to_string(UI.QueryWidget(Id("zone_ip"), :Value))
    rev_zone = Convert.to_string(UI.QueryWidget(Id("reverse_zone"), :Value))
    rev_ip = Convert.to_string(UI.QueryWidget(Id("reverse_ip"), :Value))
    key = Convert.to_string(UI.QueryWidget(Id("ddns_key"), :Value))
    rev_key = Convert.to_string(UI.QueryWidget(Id("ddns_rev_key"), :Value))
    ip = "127.0.0.1" if ip == ""
    rev_ip = "127.0.0.1" if rev_ip == ""
    if zone != ""
      zone = Ops.add(zone, ".") if !Builtins.regexpmatch(zone, "^.*\\.$")
      @current_entry_directives = Builtins.add(
        @current_entry_directives,
        {
          "key"   => "zone",
          "value" => Builtins.sformat(
            "%1 { primary %2; key %3; }",
            zone,
            ip,
            key
          )
        }
      )
    end
    if rev_zone != ""
      if !Builtins.regexpmatch(rev_zone, "^.*\\.$")
        rev_zone = Ops.add(rev_zone, ".")
      end
      @current_entry_directives = Builtins.add(
        @current_entry_directives,
        {
          "key"   => "zone",
          "value" => Builtins.sformat(
            "%1 { primary %2; key %3; }",
            rev_zone,
            rev_ip,
            rev_key
          )
        }
      )
    end
    ug = Convert.to_boolean(UI.QueryWidget(Id(:update_ddns_glob), :Value))
    DhcpServer.SetAdaptDdnsSettings(ug)
  end

  nil
end

- (Object) dhcpEnabledOrDisabled(id, event)

Enable or disable a widget according the current status of the service

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



191
192
193
194
195
196
197
198
199
200
# File '../../src/include/dhcp-server/widgets.rb', line 191

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

  nil
end

- (Boolean) DNSZonesValidate(id, event)

Validate the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that is handled

Returns:

  • (Boolean)

    true if validation succeeded



770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File '../../src/include/dhcp-server/widgets.rb', line 770

def DNSZonesValidate(id, event)
  event = deep_copy(event)
  if !Convert.to_boolean(UI.QueryWidget(Id("ddns_enable"), :Value))
    return true
  end
  ret = true
  Builtins.foreach(["zone", "zone_ip", "reverse_zone", "reverse_ip"]) do |w|
    value = Convert.to_string(UI.QueryWidget(Id(w), :Value))
    if (w == "zone" || w == "reverse_zone") &&
        Builtins.regexpmatch(value, "^.*\\.$")
      value = Builtins.regexpsub(value, "^(.*)\\.$", "\\1")
    end
    if !(Hostname.CheckFQ(value) ||
        Builtins.contains(["zone_ip", "reverse_ip"], w) && IP.Check4(value))
      UI.SetFocus(Id(w))
      Report.Error(Hostname.ValidFQ)
      ret = false
      raise Break
    end
  end
  ret
end

- (Symbol) DynDnsButtonHandle(id, event)

Handle events of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that is handled

Returns:

  • (Symbol)

    for WS



648
649
650
651
652
653
654
655
656
657
658
659
660
661
# File '../../src/include/dhcp-server/widgets.rb', line 648

def DynDnsButtonHandle(id, event)
  event = deep_copy(event)
  if Mode.config
    # popup message
    Popup.Message(
      _(
        "This function is not available during\npreparation for autoinstallation."
      )
    )
    return nil
  end
  return :tsig_keys if Builtins.size(DhcpServer.ListTSIGKeys) == 0
  :dyn_dns
end

- (Object) DynDnsButtonInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



631
632
633
634
635
636
637
638
639
640
641
642
# File '../../src/include/dhcp-server/widgets.rb', line 631

def DynDnsButtonInit(id)
  UI.ReplaceWidget(
    :_tp_table_repl,
    PushButton(
      Id("dyn_dns_button"),
      # push button
      _("&Dynamic DNS")
    )
  )

  nil
end

- (Boolean) EmptyOrIpValidate(id, event)

Validate the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that is handled

Returns:

  • (Boolean)

    true if validation succeeded



871
872
873
874
875
876
877
878
# File '../../src/include/dhcp-server/widgets.rb', line 871

def EmptyOrIpValidate(id, event)
  event = deep_copy(event)
  val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
  return true if val == "" || IP.Check4(val)
  Popup.Message(IP.Valid4)
  UI.SetFocus(Id(id))
  false
end

- (Hash) getOptionsTableWidget(add_values)

Get map of widget

Parameters:

  • add_values (Array)

    list of values to be offered via the add button

Returns:

  • (Hash)

    of widget



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
# File '../../src/include/dhcp-server/widgets.rb', line 126

def getOptionsTableWidget(add_values)
  add_values = deep_copy(add_values)
  ret = TablePopup.CreateTableDescr(
    { "add_delete_buttons" => true, "up_down_buttons" => false },
    {
      "init"                 => fun_ref(
        TablePopup.method(:TableInitWrapper),
        "void (string)"
      ),
      "handle"               => fun_ref(
        TablePopup.method(:TableHandleWrapper),
        "symbol (string, map)"
      ),
      "options"              => @popups,
      "id2key"               => fun_ref(
        method(:id2key),
        "string (map, any)"
      ),
      "ids"                  => fun_ref(
        method(:getTableContents),
        "list (map)"
      ),
      "help"                 => Ops.get(@HELPS, "options_table", ""),
      "fallback"             => {
        "init"    => fun_ref(method(:commonPopupInit), "void (any, string)"),
        "store"   => fun_ref(method(:commonPopupSave), "void (any, string)"),
        "summary" => fun_ref(
          method(:commonTableEntrySummary),
          "string (any, string)"
        )
      },
      "option_delete"        => fun_ref(
        method(:commonTableEntryDelete),
        "boolean (any, string)"
      ),
      "add_items"            => add_values,
      "add_items_keep_order" => true
    }
  )
  deep_copy(ret)
end

- (Array) getTableContents(descr)

Create list of identifiers of etries that should be present in the table

Parameters:

  • descr (Hash)

    map description of the table

Returns:

  • (Array)

    of identifiers of entries of the table



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/include/dhcp-server/widgets.rb', line 64

def getTableContents(descr)
  descr = deep_copy(descr)
  index = -1
  opts = Builtins.maplist(@current_entry_options) do |m|
    index = Ops.add(index, 1)
    Builtins.sformat("option %1", index)
  end

  index = -1
  dirs = Builtins.maplist(@current_entry_directives) do |m|
    index = Ops.add(index, 1)
    if Ops.get_string(m, "key", "") != "zone"
      next Builtins.sformat("directive %1", index)
    end
    nil
  end
  Builtins.filter(
    Convert.convert(
      Builtins.merge(dirs, opts),
      :from => "list",
      :to   => "list <string>"
    )
  ) { |id| id != nil }
end

- (String) id2key(table, id)

Transform table entry id to option id

Parameters:

  • table (Hash)

    map table description

  • id (Object)

    any entry id

Returns:

  • (String)

    option key



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File '../../src/include/dhcp-server/widgets.rb', line 93

def id2key(table, id)
  table = deep_copy(table)
  id = deep_copy(id)
  return "" if !Ops.is_string?(id)
  strid = Convert.to_string(id)
  if Builtins.substring(strid, 0, 7) == "option "
    index = Builtins.tointeger(Builtins.substring(strid, 7))
    return Builtins.sformat(
      "option %1",
      Ops.get(@current_entry_options, [index, "key"], "")
    )
  elsif Builtins.substring(strid, 0, 10) == "directive "
    index = Builtins.tointeger(Builtins.substring(strid, 10))
    return Ops.get(@current_entry_directives, [index, "key"], "")
  end
  strid
end

- (Object) idInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



587
588
589
590
591
# File '../../src/include/dhcp-server/widgets.rb', line 587

def idInit(id)
  UI.ChangeWidget(Id(id), :Value, @current_entry_id)

  nil
end

- (Object) idStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



596
597
598
599
600
601
# File '../../src/include/dhcp-server/widgets.rb', line 596

def idStore(id, event)
  event = deep_copy(event)
  @current_entry_id = Convert.to_string(UI.QueryWidget(Id(id), :Value))

  nil
end

- (Object) initialize_dhcp_server_widgets(include_target)



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File '../../src/include/dhcp-server/widgets.rb', line 15

def initialize_dhcp_server_widgets(include_target)
  textdomain "dhcp-server"

  Yast.import "CWM"
  Yast.import "CWMTsigKeys"
  Yast.import "DhcpServer"
  Yast.import "Hostname"
  Yast.import "IP"
  Yast.import "Label"
  Yast.import "LogView"
  Yast.import "Popup"
  Yast.import "TablePopup"
  Yast.import "SuSEFirewall"
  Yast.import "Mode"
end

- (Object) InitWidgets

Initialize widgets Create description map and copy it into appropriate variable of the DhcpServer module



922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
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
1153
1154
1155
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
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
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
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
# File '../../src/include/dhcp-server/widgets.rb', line 922

def InitWidgets
  options = [
    "option subnet-mask",
    "option broadcast-address",
    "option routers",
    "option static-routes",
    "option domain-name",
    "option domain-name-servers",
    "option host-name",
    "option root-path",
    "option tftp-server-name",
    "option bootfile-name",
    "option dhcp-server-identifier",
    "option time-servers",
    "option ntp-servers",
    "option log-servers",
    "option lpr-servers",
    "option font-servers",
    "option x-display-managers",
    "option smtp-server",
    "option pop-server",
    "option irc-server",
    "option nis-domain",
    "option nis-servers",
    "option nisplus-domain",
    "option nisplus-servers",
    "option interface-mtu",
    "option vendor-encapsulated-options",
    "option vendor-class-identifier",
    "option netbios-name-servers",
    "option netbios-dd-server",
    "option netbios-node-type",
    "option netbios-scope"
  ]

  common_commands = [
    "max-lease-time",
    "default-lease-time",
    "filename",
    "next-server",
    "allow",
    "deny"
  ]

  global_commands = [
    "authoritative",
    "ddns-update-style",
    "ddns-updates",
    "log-facility",
    # FATE #227
    "ldap-dhcp-server-cn"
  ]

  subnet_commands = ["range"]

  host_commands = ["hardware", "fixed-address"]

  class_commands = ["match"]

  shared_net_commands = []

  pool_commands = ["range"]

  group_commands = []

  common_commands = optsort(
    Convert.convert(
      Builtins.merge(common_commands, options),
      :from => "list",
      :to   => "list <string>"
    )
  )
  global_commands = optsort(
    Convert.convert(
      Builtins.merge(global_commands, common_commands),
      :from => "list",
      :to   => "list <string>"
    )
  )
  subnet_commands = optsort(
    Convert.convert(
      Builtins.merge(subnet_commands, common_commands),
      :from => "list",
      :to   => "list <string>"
    )
  )
  host_commands = optsort(
    Convert.convert(
      Builtins.merge(host_commands, common_commands),
      :from => "list",
      :to   => "list <string>"
    )
  )
  shared_net_commands = optsort(
    Convert.convert(
      Builtins.merge(shared_net_commands, common_commands),
      :from => "list",
      :to   => "list <string>"
    )
  )
  pool_commands = optsort(
    Convert.convert(
      Builtins.merge(pool_commands, common_commands),
      :from => "list",
      :to   => "list <string>"
    )
  )
  group_commands = optsort(
    Convert.convert(
      Builtins.merge(group_commands, common_commands),
      :from => "list",
      :to   => "list <string>"
    )
  )

  w = {
    "global_table"         => getOptionsTableWidget(global_commands),
    "host_table"           => getOptionsTableWidget(host_commands),
    "subnet_table"         => getOptionsTableWidget(subnet_commands),
    "shared-network_table" => getOptionsTableWidget(shared_net_commands),
    "pool_table"           => getOptionsTableWidget(pool_commands),
    "group_table"          => getOptionsTableWidget(group_commands),
    "class_table"          => getOptionsTableWidget(class_commands),
    "dyn_dns_button"       => {
      "init"          => fun_ref(method(:DynDnsButtonInit), "void (string)"),
      "handle"        => fun_ref(
        method(:DynDnsButtonHandle),
        "symbol (string, map)"
      ),
      "handle_events" => ["dyn_dns_button"],
      "help"          => Ops.get(@HELPS, "dyn_dns_button", ""),
      "label"         => "&D ",
      #FIXME CWM should be able to handle virtual widgets
      "widget"        => :textentry
    },
    "start"                => {
      "widget" => :checkbox,
      # check box
      "label"  => _("&Start DHCP Server"),
      "help"   => Ops.get(@HELPS, "start", ""),
      "init"   => fun_ref(method(:startInit), "void (string)"),
      "handle" => fun_ref(method(:startHandle), "symbol (string, map)"),
      "store"  => fun_ref(method(:startStore), "void (string, map)"),
      "opt"    => [:notify]
    },
    "chroot"               => {
      "widget" => :checkbox,
      # check box
      "label"  => _("&Run DHCP Server in Chroot Jail"),
      "help"   => Ops.get(@HELPS, "chroot", ""),
      "init"   => fun_ref(method(:chrootInit), "void (string)"),
      "handle" => fun_ref(method(:chrootHandle), "symbol (string, map)"),
      "store"  => fun_ref(method(:chrootStore), "void (string, map)")
    },
    "ldap_support"         => {
      "widget" => :checkbox,
      # check box
      "label"  => _("&LDAP Support"),
      "help"   => Ops.get(@HELPS, "ldap_support", " "),
      "init"   => fun_ref(method(:ldapInit), "void (string)"),
      "handle" => fun_ref(method(:ldapHandle), "symbol (string, map)"),
      "opt"    => [:notify]
    },
    "configtree"           => {
      "widget"        => :custom,
      "custom_widget" => VWeight(
        1,
        VBox(
          VWeight(
            1,
            ReplacePoint(
              Id(:configtree_rp),
              Tree(
                Id("configtree"),
                # tree widget
                _("&Configured Declarations"),
                []
              )
            )
          ),
          HBox(
            PushButton(Id(:add), Label.AddButton),
            PushButton(Id(:edit), Label.EditButton),
            PushButton(Id(:delete), Label.DeleteButton),
            #			`PushButton (`id (`move), _("&Move")),
            HStretch(),
            # menu button
            MenuButton(
              Id(:adv),
              _("Ad&vanced"),
              [
                # item of a menu button
                Item(Id(:log), _("Display &Log")),
                # item of a menu button
                Item(Id(:interfaces), _("&Interface Configuration")),
                # item of a menu button
                Item(Id(:tsig_keys), _("TSIG Key Management"))
              ]
            )
          )
        )
      ),
      "help"          => Ops.get(@HELPS, "configtree", ""),
      "init"          => fun_ref(method(:configTreeInit), "void (string)"),
      "handle"        => fun_ref(
        method(:configTreeHandle),
        "symbol (string, map)"
      )
    },
    "subnet"               => {
      "widget"        => :custom,
      "custom_widget" => HBox(
        HSpacing(2),
        # text entry
        TextEntry(Id(:subnet), _("&Network Address")),
        # text entry
        TextEntry(Id(:netmask), _("Network &Mask")),
        HSpacing(2)
      ),
      "help"          => Ops.get(@HELPS, "subnet", ""),
      "init"          => fun_ref(method(:subnetInit), "void (string)"),
      "store"         => fun_ref(method(:subnetStore), "void (string, map)")
    },
    "host"                 => {
      "widget" => :textentry,
      # text entry
      "label"  => Label.HostName,
      "help"   => Ops.get(@HELPS, "host", ""),
      "init"   => fun_ref(method(:idInit), "void (string)"),
      "store"  => fun_ref(method(:idStore), "void (string, map)")
    },
    "group"                => {
      "widget" => :textentry,
      # text entry
      "label"  => _("Group &Name"),
      "help"   => Ops.get(@HELPS, "group", ""),
      "init"   => fun_ref(method(:idInit), "void (string)"),
      "store"  => fun_ref(method(:idStore), "void (string, map)")
    },
    "pool"                 => {
      "widget" => :textentry,
      # text entry
      "label"  => _("Pool &Name"),
      "help"   => Ops.get(@HELPS, "pool", ""),
      "init"   => fun_ref(method(:idInit), "void (string)"),
      "store"  => fun_ref(method(:idStore), "void (string, map)")
    },
    "shared-network"       => {
      "widget" => :textentry,
      # text entry
      "label"  => _("Shared Network &Name"),
      "help"   => Ops.get(@HELPS, "shared-network", ""),
      "init"   => fun_ref(method(:idInit), "void (string)"),
      "store"  => fun_ref(method(:idStore), "void (string, map)")
    },
    "class"                => {
      "widget" => :textentry,
      # text entry
      "label"  => _("Class &Name"),
      "help"   => Ops.get(@HELPS, "class", ""),
      "init"   => fun_ref(method(:idInit), "void (string)"),
      "store"  => fun_ref(method(:idStore), "void (string, map)")
    },
    "interfaces"           => {
      "widget"        => :custom,
      "custom_widget" => MultiSelectionBox(
        Id("interfaces"),
        # multi selection box
        _("Available Interfaces"),
        Builtins.maplist(Builtins.filter(SCR.Dir(path(".network.section"))) do |s|
          s != "lo"
        end) { |s| Item(Id(s), s) }
      ),
      "help"          => Ops.get(@HELPS, "interfaces", ""),
      "init"          => fun_ref(method(:interfacesInit), "void (string)"),
      "store"         => fun_ref(
        method(:interfacesStore),
        "void (string, map)"
      )
    },
    "open_firewall"        => {
      "widget"            => :checkbox,
      # check box
      "label"             => _(
        "Open &Firewall for Selected Interfaces"
      ),
      "init"              => fun_ref(
        method(:OpenFirewallInit),
        "void (string)"
      ),
      "store"             => fun_ref(
        method(:OpenFirewallStore),
        "void (string, map)"
      ),
      "validate_type"     => :function,
      "validate_function" => fun_ref(
        method(:OpenFirewallValidate),
        "boolean (string, map)"
      ),
      "help"              => Ops.get(@HELPS, "open_firewall", "")
    },
    "ddns_enable"          => {
      "widget"        => :custom,
      "custom_widget" => VBox(
        Left(
          CheckBox(
            Id("ddns_enable"),
            Opt(:notify),
            # check box
            _("&Enable Dynamic DNS for This Subnet")
          )
        ),
        VSpacing(0.5),
        Left(
          ReplacePoint(
            Id(:ddns_key_rp),
            # combo box
            ComboBox(Id("ddns_key"), _("Forward Zone TSIG &Key"))
          )
        ),
        Left(
          ReplacePoint(
            Id(:rev_ddns_key_rp),
            # combo box
            ComboBox(Id("rev_ddns_key"), _("Reverse Zone TSIG &Key"))
          )
        ),
        Left(
          CheckBox(
            Id(:update_ddns_glob),
            # check box
            _("&Update Global Dynamic DNS Settings")
          )
        )
      ),
      # check box
      "help"          => Ops.get(@HELPS, "enable_ddns", "")
    },
    "zone"                 => {
      "widget"            => :textentry,
      # text entry
      "label"             => _("&Zone"),
      "init"              => fun_ref(
        method(:DDNSZonesInit),
        "void (string)"
      ),
      "store"             => fun_ref(
        method(:DDNSZonesStore),
        "void (string, map)"
      ),
      "handle"            => fun_ref(
        method(:DDNSZonesHandle),
        "symbol (string, map)"
      ),
      "handle_events"     => ["ddns_enable"],
      "help"              => Ops.get(@HELPS, "ddns_zones", ""),
      "validate_type"     => :function,
      "validate_function" => fun_ref(
        method(:DNSZonesValidate),
        "boolean (string, map)"
      )
    },
    "zone_ip" =>
      #	    "validate_type" : `function,
      #	    "validate_function" : EmptyOrIpValidate,
      {
        "widget" => :textentry,
        # text entry
        "label"  => _("&Primary DNS Server"),
        "help"   => " "
      },
    "reverse_zone"         => {
      "widget" => :textentry,
      # text entry
      "label"  => _("Re&verse Zone"),
      "help"   => " "
    },
    "reverse_ip" =>
      #	    "validate_type" : `function,
      #	    "validate_function" : EmptyOrIpValidate,
      {
        "widget" => :textentry,
        # text entry
        "label"  => _("Pr&imary DNS Server"),
        "help"   => " "
      },
    "tsig_keys"            => CWMTsigKeys.CreateWidget(
      {
        "get_keys_info"  => fun_ref(
          DhcpServer.method(:GetKeysInfo),
          "map <string, any> ()"
        ),
        "set_keys_info"  => fun_ref(
          DhcpServer.method(:SetKeysInfo),
          "void (map <string, any>)"
        ),
        "list_used_keys" => fun_ref(
          DhcpServer.method(:ListUsedKeys),
          "list <string> ()"
        )
      }
    ),
    "config_summary"       => {
      "widget"        => :custom,
      "custom_widget" => RichText(Id("config_summary"), ""),
      "init"          => fun_ref(
        method(:ConfigSummaryInit),
        "void (string)"
      )
    },
    "all_settings_button"  => {
      "widget"        => :push_button,
      # push button
      "label"         => _(
        "DHCP Server &Expert Configuration..."
      ),
      "handle_events" => ["all_settings_button"],
      "handle"        => fun_ref(
        method(:AllSettingsButtonHandle),
        "symbol (string, map)"
      ),
      "help"          => Ops.get(@HELPS, "all_settings_button", "")
    }
  }
  @widgets = deep_copy(w)

  nil
end

- (Object) interfacesInit(id)

Initialize the widget

Parameters:

  • id (String)

    string widget id



605
606
607
608
609
610
# File '../../src/include/dhcp-server/widgets.rb', line 605

def interfacesInit(id)
  allowed_ifaces = DhcpServer.GetAllowedInterfaces
  UI.ChangeWidget(Id(id), :SelectedItems, allowed_ifaces)

  nil
end

- (Object) interfacesStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



615
616
617
618
619
620
621
622
623
624
625
626
627
# File '../../src/include/dhcp-server/widgets.rb', line 615

def interfacesStore(id, event)
  event = deep_copy(event)
  selected_ifaces = Convert.to_list(UI.QueryWidget(Id(id), :SelectedItems))
  interfaces = Convert.convert(
    selected_ifaces,
    :from => "list",
    :to   => "list <string>"
  )
  DhcpServer.SetAllowedInterfaces(interfaces)
  DhcpServer.SetModified

  nil
end

- (Hash) key2descr(opt_key)

Get the popup widget description map

Parameters:

  • opt_key (String)

    string option key

Returns:

  • (Hash)

    popup description map



114
115
116
117
118
119
120
121
# File '../../src/include/dhcp-server/widgets.rb', line 114

def key2descr(opt_key)
  ret = Ops.get_map(@popups, opt_key)
  return deep_copy(ret) if ret != nil
  {
    "init"  => fun_ref(method(:commonPopupInit), "void (any, string)"),
    "store" => fun_ref(method(:commonPopupSave), "void (any, string)")
  }
end

- (Symbol) KeyFileBrowseButtonHandle(id, event)

Handle events of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that is handled

Returns:

  • (Symbol)

    for WS



854
855
856
857
858
859
860
861
862
863
864
865
# File '../../src/include/dhcp-server/widgets.rb', line 854

def KeyFileBrowseButtonHandle(id, event)
  event = deep_copy(event)
  filename = Convert.to_string(UI.QueryWidget(Id("key_filename"), :Value))
  filename = UI.AskForExistingFile(
    filename,
    "",
    # popup headline
    _("Select File with Authentication Key")
  )
  UI.ChangeWidget(Id("key_filename"), :Value, filename) if filename != nil
  nil
end

- (Symbol) ldapHandle(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



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File '../../src/include/dhcp-server/widgets.rb', line 307

def ldapHandle(id, event)
  event = deep_copy(event)
  if Ops.get(event, "ID") == "start"
    en = Convert.to_boolean(UI.QueryWidget(Id("start"), :Value))
    UI.ChangeWidget(Id(id), :Enabled, en)
    return nil
  end
  ldap = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
  if ldap != DhcpServer.GetUseLdap
    SetUseLdap(ldap)
    ldap = DhcpServer.GetUseLdap
    UI.ChangeWidget(Id(id), :Value, ldap)
  end
  nil
end

- (Object) ldapInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



276
277
278
279
280
281
282
283
284
285
286
287
288
# File '../../src/include/dhcp-server/widgets.rb', line 276

def ldapInit(id)
  ul = DhcpServer.GetUseLdap
  ldap_available = DhcpServer.GetLdapAvailable
  UI.ChangeWidget(Id(id), :Value, ul)

  if ldap_available
    ldapHandle(id, { "ID" => "start" })
  else
    UI.ChangeWidget(Id(id), :Enabled, ldap_available)
  end

  nil
end

- (Object) OpenFirewallInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



326
327
328
329
330
331
332
333
# File '../../src/include/dhcp-server/widgets.rb', line 326

def OpenFirewallInit(id)
  enabled = SuSEFirewall.GetEnableService
  open = DhcpServer.GetOpenFirewall
  UI.ChangeWidget(Id(id), :Enabled, enabled)
  UI.ChangeWidget(Id(id), :Value, open)

  nil
end

- (Object) OpenFirewallStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



338
339
340
341
342
343
344
345
# File '../../src/include/dhcp-server/widgets.rb', line 338

def OpenFirewallStore(id, event)
  event = deep_copy(event)
  open = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
  DhcpServer.SetOpenFirewall(open)
  DhcpServer.SetModified

  nil
end

- (Object) OpenFirewallValidate(id, event)



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
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
406
407
408
409
410
# File '../../src/include/dhcp-server/widgets.rb', line 347

def OpenFirewallValidate(id, event)
  event = deep_copy(event)
  open = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
  enabled = SuSEFirewall.GetEnableService

  if enabled && !open
    # yes-no popup
    if !Popup.YesNo(
        _(
          "The port in firewall is not open. The DHCP server\n" +
            "will not be able to serve your network.\n" +
            "Continue?"
        )
      )
      return false
    end
  end

  # firewall is enabled
  if enabled
    # active interfaces not mentioned in firewall
    ifaces_not_in_fw = []
    Builtins.foreach(@ifaces) do |ifcfg, interface|
      # interface is active
      if Ops.get_boolean(interface, "active", false) == true
        if SuSEFirewall.GetZoneOfInterface(ifcfg) == nil
          ifaces_not_in_fw = Builtins.add(ifaces_not_in_fw, ifcfg)
        end
      end
    end

    # more than one
    if Ops.greater_than(Builtins.size(ifaces_not_in_fw), 1)
      Report.Error(
        Builtins.sformat(
          # TRANSLATORS: popup error message, %1 is list of network interfaces
          _(
            "The network interfaces listed below are not mentioned in any firewall zone.\n" +
              "%1\n" +
              "Run the YaST firewall configuration to assign them to a zone."
          ),
          Builtins.mergestring(ifaces_not_in_fw, "\n")
        )
      ) 
      #return false;
      # FIXME: dialog for adding interfaces into firewall zones
      # only one
    elsif Ops.greater_than(Builtins.size(ifaces_not_in_fw), 0)
      Report.Error(
        Builtins.sformat(
          # TRANSLATORS: popup error message, %1 a network interface name
          _(
            "Network interface %1 is not mentioned in any firewall zone.\nRun the YaST firewall configuration to assign it to a zone."
          ),
          Ops.get(ifaces_not_in_fw, 0, "")
        )
      ) 
      #return false;
      # FIXME: dialog for adding interfaces into firewall zones
    end
  end

  true
end

- (Object) optsort(options)



882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
# File '../../src/include/dhcp-server/widgets.rb', line 882

def optsort(options)
  options = deep_copy(options)
  options = Builtins.toset(options)
  options = Builtins.sort(options)

  o1 = Builtins.filter(options) do |o|
    Builtins.regexpmatch(o, "^option .+$")
  end

  o2 = Builtins.filter(options) do |o|
    !Builtins.regexpmatch(o, "^option .+$")
  end
  Convert.convert(
    Builtins.merge(o2, o1),
    :from => "list",
    :to   => "list <string>"
  )
end

- (Object) SetUseLdap(use_ldap)

Set the LDAP usage, reinitalize LDAP support

Parameters:

  • use_ldap (Boolean)

    boolean true if LDAP is to be used



292
293
294
295
296
297
298
299
300
301
# File '../../src/include/dhcp-server/widgets.rb', line 292

def SetUseLdap(use_ldap)
  DhcpServer.SetUseLdap(use_ldap)
  if !Mode.config
    DhcpServer.InitYapiConfigOptions({ "use_ldap" => use_ldap })
    DhcpServer.LdapInit([], true)
    DhcpServer.CleanYapiConfigOptions
  end

  nil
end

- (Symbol) startHandle(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



226
227
228
229
230
231
# File '../../src/include/dhcp-server/widgets.rb', line 226

def startHandle(id, event)
  event = deep_copy(event)
  start = Convert.to_boolean(UI.QueryWidget(Id("start"), :Value))
  DhcpServer.SetModified if start != DhcpServer.GetStartService
  nil
end

- (Object) startInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



204
205
206
207
208
209
# File '../../src/include/dhcp-server/widgets.rb', line 204

def startInit(id)
  ss = DhcpServer.GetStartService
  UI.ChangeWidget(Id("start"), :Value, ss)

  nil
end

- (Object) startStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



214
215
216
217
218
219
220
# File '../../src/include/dhcp-server/widgets.rb', line 214

def startStore(id, event)
  event = deep_copy(event)
  ss = Convert.to_boolean(UI.QueryWidget(Id("start"), :Value))
  DhcpServer.SetStartService(ss)

  nil
end

- (Object) subnetInit(id)

Initialize the widget

Parameters:

  • id (String)

    any widget id



559
560
561
562
563
564
565
566
567
568
# File '../../src/include/dhcp-server/widgets.rb', line 559

def subnetInit(id)
  l = Builtins.regexptokenize(
    @current_entry_id,
    "^[ \t]*([^ \t]+)[ \t]*netmask[ \t]*([^ \t]+)[ \t]*$"
  )
  UI.ChangeWidget(Id(:subnet), :Value, Ops.get(l, 0, ""))
  UI.ChangeWidget(Id(:netmask), :Value, Ops.get(l, 1, ""))

  nil
end

- (Object) subnetStore(id, event)

Store settings of the widget

Parameters:

  • id (String)

    string widget id

  • event (Hash)

    map event that caused storing process



573
574
575
576
577
578
579
580
581
582
583
# File '../../src/include/dhcp-server/widgets.rb', line 573

def subnetStore(id, event)
  event = deep_copy(event)
  id = Builtins.sformat(
    "%1 netmask %2",
    Convert.to_string(UI.QueryWidget(Id(:subnet), :Value)),
    Convert.to_string(UI.QueryWidget(Id(:netmask), :Value))
  )
  @current_entry_id = id

  nil
end