Module: Yast::SlpServerDialogsInclude

Defined in:
../../src/include/slp-server/dialogs.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) changeResponseTo(resp)

internal function: changing response



755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
# File '../../src/include/slp-server/dialogs.rb', line 755

def changeResponseTo(resp)
  case resp
    when :bc
      Builtins.y2milestone("Use broadcast")
      UI.ChangeWidget(Id(:ip), :Enabled, false)
      UI.ChangeWidget(Id(:scope), :Enabled, false)
      Ops.set(SlpServer.slp_config, "net.slp.isDA", "false")
      Ops.set(SlpServer.slp_config, "net.slp.isBroadcastOnly", "true")
    when :mc
      Builtins.y2milestone("Use multicast")
      UI.ChangeWidget(Id(:ip), :Enabled, false)
      UI.ChangeWidget(Id(:scope), :Enabled, true)
      Ops.set(SlpServer.slp_config, "net.slp.isDA", "false")
      Ops.set(SlpServer.slp_config, "net.slp.isBroadcastOnly", "false")
    when :da
      Builtins.y2milestone("Use DA Server")
      UI.ChangeWidget(Id(:ip), :Enabled, true)
      UI.ChangeWidget(Id(:scope), :Enabled, true)
      Ops.set(SlpServer.slp_config, "net.slp.isDA", "false")
    when :da_server
      Builtins.y2milestone("Becomes DA Server")
      UI.ChangeWidget(Id(:ip), :Enabled, false)
      #                UI::ChangeWidget(`id(`scope), `Enabled, false);
      Ops.set(SlpServer.slp_config, "net.slp.isDA", "true")
  end

  nil
end

- (Object) deleteReg(opt_id, opt_key)



643
644
645
646
647
648
649
650
651
# File '../../src/include/slp-server/dialogs.rb', line 643

def deleteReg(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  if Ops.get_string(@reg_files_pkg, opt_key, "") == ""
    @keys = Builtins.filter(@keys) { |val| val != opt_key }
    return true
  else
    return false
  end
end

- (Object) editRegFile

edit reg file dialog



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
# File '../../src/include/slp-server/dialogs.rb', line 954

def editRegFile
  @current_tab = "static"
  caption = _("SLP Server Configuration--Edit .reg File")

  w = CWM.CreateWidgets(["regedit_table"], @widgets)
  contents = HBox(
    HSpacing(1),
    VBox(VSpacing(1), Ops.get_term(w, [0, "widget"]) { VSpacing(1) }),
    HSpacing(1)
  )
  help = CWM.MergeHelps(w)
  contents = CWM.PrepareDialog(contents, w)
  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "regedit", ""),
    Label.BackButton,
    Label.NextButton
  )

  ret = CWM.Run(
    w,
    { :abort => fun_ref(method(:ReallyAbort), "boolean ()") }
  )
  deep_copy(ret)
end

- (Object) ExpertDialog

dialog for expert settings



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
# File '../../src/include/slp-server/dialogs.rb', line 925

def ExpertDialog
  @current_tab = "server"
  @copy_config = deep_copy(SlpServer.slp_config)
  caption = _("SLP Server Configuration--Expert Dialog")

  w = CWM.CreateWidgets(["server_table"], @widgets)
  contents = HBox(
    HSpacing(1),
    VBox(VSpacing(1), Ops.get_term(w, [0, "widget"]) { VSpacing(1) }),
    HSpacing(1)
  )
  help = CWM.MergeHelps(w)
  contents = CWM.PrepareDialog(contents, w)
  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "expert", ""),
    Label.BackButton,
    Label.NextButton
  )

  ret = CWM.Run(
    w,
    { :abort => fun_ref(method(:ReallyAbort), "boolean ()") }
  )
  deep_copy(ret)
end

- (Object) getRegEditOptions



501
502
503
# File '../../src/include/slp-server/dialogs.rb', line 501

def getRegEditOptions
  { "tcp-port" => {}, "description" => {}, "service" => {} }
end

- (Object) getServerOptions



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
411
412
413
414
415
# File '../../src/include/slp-server/dialogs.rb', line 363

def getServerOptions
  {
    "net.slp.useScopes"                 => {},
    "net.slp.DAAddresses"               => {},
    "net.slp.isDA"                      => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.DAHeartBeat"               => {},
    "net.slp.watchRegistrationPID"      => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.maxResults"                => {},
    "net.slp.isBroadcastOnly"           => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.passiveDADetection"        => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.activeDADetection"         => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.DAActiveDiscoveryInterval" => {},
    "net.slp.multicastTTL"              => {},
    "net.slp.DADiscoveryMaximumWait"    => {},
    "net.slp.DADiscoveryTimeouts"       => {},
    "net.slp.multicastMaximumWait"      => {},
    "net.slp.multicastTimeouts"         => {},
    "net.slp.unicastMaximumWait"        => {},
    "net.slp.unicastTimeouts"           => {},
    "net.slp.datagramTimeouts"          => {},
    "net.slp.randomWaitBound"           => {},
    "net.slp.MTU"                       => {},
    "net.slp.interfaces"                => {},
    "net.slp.securityEnabled"           => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.checkSourceAddr"           => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.traceDATraffic"            => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.traceReg"                  => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.traceDrop"                 => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    },
    "net.slp.traceMsg"                  => {
      "popup" => { "items" => [["true"], ["false"]], "widget" => :combobox }
    }
  }
end

- (Object) handleExpert(key, event)



742
743
744
745
746
747
748
749
# File '../../src/include/slp-server/dialogs.rb', line 742

def handleExpert(key, event)
  event = deep_copy(event)
  if Ops.get(event, "ID") == :expert
    # goto ExpertDialog (server_table)
    return :expert
  end
  nil
end

- (Object) handleRegTable(key, event)



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
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
# File '../../src/include/slp-server/dialogs.rb', line 652

def handleRegTable(key, event)
  event = deep_copy(event)
  if Ops.get(event, "ID") == :_tp_edit
    @currentRegFile = Convert.to_string(
      UI.QueryWidget(:_tp_table, :CurrentItem)
    )
    return :edit
  end
  if Ops.get(event, "ID") == :_tp_delete
    @currentRegFile = Convert.to_string(
      UI.QueryWidget(:_tp_table, :CurrentItem)
    )
    package = Ops.get_string(@reg_files_pkg, @currentRegFile, "")
    if package == ""
      if Popup.ContinueCancel(_("Really delete this file?"))
        SlpServer.reg_files = Builtins.maplist(SlpServer.reg_files) do |s|
          if Ops.get_string(s, "name", "") == @currentRegFile
            Ops.set(s, "value", nil)
          end
          deep_copy(s)
        end
        initReg("")
      end
    else
      Popup.Error(
        Builtins.sformat(
          "Reg file %1 is owned by package %2",
          @currentRegFile,
          package
        )
      )
    end
  end
  if Ops.get(event, "ID") == :_tp_add
    UI.OpenDialog(
      VBox(
        # translators: combo box for selsect module from installed unknown modules
        TextEntry(Id(:filename), _("Name of New File")),
        ButtonBox(
          PushButton(Id(:ok), Opt(:default), Label.OKButton),
          PushButton(Id(:cancel), Label.CancelButton)
        )
      )
    )

    UI.SetFocus(Id(:filename))

    ret = Convert.to_symbol(UI.UserInput)

    if ret == :ok
      filename = Builtins.sformat(
        "/etc/slp.reg.d/%1",
        Convert.to_string(UI.QueryWidget(Id(:filename), :Value))
      )
      if Builtins.contains(@keys, filename)
        Popup.Error("File with that name already exists")
      else
        SlpServer.reg_files = Builtins.add(
          SlpServer.reg_files,
          {
            "name"    => filename,
            "value"   => [],
            "type"    => -1,
            "file"    => -1,
            "kind"    => "section",
            "comment" => ""
          }
        )
      end
    end
    UI.CloseDialog
    initReg("")
  end
  nil
end

- (Object) handleServerSettings(key, event)



824
825
826
827
828
829
830
# File '../../src/include/slp-server/dialogs.rb', line 824

def handleServerSettings(key, event)
  event = deep_copy(event)
  if Ops.get_string(event, "EventReason", "") == "ValueChanged"
    changeResponseTo(Ops.get_symbol(event, "WidgetID", :nil))
  end
  nil
end

- (Object) handleShowLog(key, event)



727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
# File '../../src/include/slp-server/dialogs.rb', line 727

def handleShowLog(key, event)
  event = deep_copy(event)
  if Ops.get(event, "ID") == :show_log
    log = ""
    log = Ops.get(Builtins.splitstring(log, " "), 0, "/var/log/slpd.log")

    LogView.Display(
      {
        "command" => Builtins.sformat("tail -f %1 -n 100", log),
        "save"    => false
      }
    )
  end
  nil
end

- (Object) Id2Key(desc, option_id)



329
330
331
332
333
# File '../../src/include/slp-server/dialogs.rb', line 329

def Id2Key(desc, option_id)
  desc = deep_copy(desc)
  option_id = deep_copy(option_id)
  Convert.to_string(option_id)
end

- (Object) Id2RegEditKey(desc, option_id)



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File '../../src/include/slp-server/dialogs.rb', line 522

def Id2RegEditKey(desc, option_id)
  desc = deep_copy(desc)
  option_id = deep_copy(option_id)
  ret = ""
  Builtins.foreach(@reg_file) do |row|
    if Builtins.haskey(row, option_id)
      ret = Ops.get_string(
        Ops.get(@reg_file, Builtins.tointeger(option_id)),
        [Builtins.tostring(option_id), "KEY"],
        ""
      )
    end
  end
  ret
end

- (Object) Id2RegKey(desc, option_id)



612
613
614
615
616
# File '../../src/include/slp-server/dialogs.rb', line 612

def Id2RegKey(desc, option_id)
  desc = deep_copy(desc)
  option_id = deep_copy(option_id)
  Convert.to_string(option_id)
end

- (Object) initExpert(key)



309
310
311
312
313
# File '../../src/include/slp-server/dialogs.rb', line 309

def initExpert(key)
  TablePopup.TableInit(CWM.GetProcessedWidget, key)

  nil
end

- (Object) initialize_slp_server_dialogs(include_target)



11
12
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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
210
211
212
213
214
215
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
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
# File '../../src/include/slp-server/dialogs.rb', line 11

def initialize_slp_server_dialogs(include_target)
  textdomain "slp-server"

  Yast.import "Label"
  Yast.import "Wizard"
  Yast.import "SlpServer"
  Yast.import "CWMTab"
  Yast.import "CWM"
  Yast.import "CWMServiceStart"
  Yast.import "CWMFirewallInterfaces"
  Yast.import "TablePopup"
  Yast.import "LogView"
  Yast.import "IP"
  Yast.import "String"
  Yast.import "Address"
  Yast.include include_target, "slp-server/helps.rb"
  @reg_file = []

  @current_tab = "general"
  @keys = []
  @copy_config = {}
  @reg_files_pkg = {}
  @currentRegFile = ""


  @widgets = {
    # service status widget
    "auto_start_up"   => CWMServiceStart.CreateAutoStartWidget(
      {
        "get_service_auto_start" => fun_ref(
          SlpServer.method(:GetStartService),
          "boolean ()"
        ),
        "set_service_auto_start" => fun_ref(
          SlpServer.method(:SetStartService),
          "void (boolean)"
        ),
        # radio button (starting SLP service - option 1)
        "start_auto_button"      => _(
          "When &Booting"
        ),
        # radio button (starting SLP service - option 2)
        "start_manual_button"    => _(
          "&Manually"
        ),
        "help"                   => Builtins.sformat(
          CWMServiceStart.AutoStartHelpTemplate,
          # part of help text, used to describe radiobuttons (matching starting SLP service but without "&")
          _("When Booting"),
          # part of help text, used to describe radiobuttons (matching starting SLP service but without "&")
          _("Manually")
        )
      }
    ),
    # firewall widget
    "firewall"        => CWMFirewallInterfaces.CreateOpenFirewallWidget(
      { "services" => ["slp-daemon"], "display_details" => true }
    ),
    # button for view log files
    "view_log"        => {
      "widget"        => :custom,
      "custom_widget" => VBox(PushButton(Id(:show_log), _("Show Log"))),
      "handle"        => fun_ref(
        method(:handleShowLog),
        "symbol (string, map)"
      ),
      "label"         => _("Show Log"),
      "help"          => Ops.get_string(@HELPS, "show_log", "")
    },
    # button for expert settings (all config options)
    "expert"          => {
      "widget"        => :custom,
      "custom_widget" => VBox(PushButton(Id(:expert), _("Expert Settings"))),
      "handle"        => fun_ref(
        method(:handleExpert),
        "symbol (string, map)"
      ),
      "label"         => _("Expert Settings"),
      "help"          => Ops.get_string(@HELPS, "expert", "")
    },
    # response + scopes widget
    "server_settings" => {
      "widget"            => :custom,
      "custom_widget"     => VBox(
        RadioButtonGroup(
          Id(:resp),
          VBox(
            Label(_("Response To")),
            Left(RadioButton(Id(:bc), Opt(:notify), _("Broadcast"))),
            Left(RadioButton(Id(:mc), Opt(:notify), _("Multicast"))),
            Left(RadioButton(Id(:da), Opt(:notify), _("DA Server"))),
            Left(
              RadioButton(
                Id(:da_server),
                Opt(:notify),
                _("Becomes DA Server")
              )
            )
          )
        ),
        TextEntry(Id(:ip), _("&IP Addresses of DA Servers")),
        TextEntry(Id(:scope), _("&Scopes"))
      ),
      "init"              => fun_ref(
        method(:initServerSettings),
        "void (string)"
      ),
      "handle"            => fun_ref(
        method(:handleServerSettings),
        "symbol (string, map)"
      ),
      "store"             => fun_ref(
        method(:storeServerSettings),
        "void (string, map)"
      ),
      "validate_type"     => :function,
      "validate_function" => fun_ref(
        method(:validateServerSettings),
        "boolean (string, map)"
      ),
      "label"             => _("SLP Server Settings"),
      "help"              => Ops.get_string(@HELPS, "server_settings", "")
    },
    # expert settings ;)
    "server_table"    => TablePopup.CreateTableDescr(
      {
        "add_delete_buttons" => true,
        "up_down_buttons"    => false,
        "unique_keys"        => true
      },
      {
        "init"          => fun_ref(method(:initExpert), "void (string)"),
        "store"         => fun_ref(
          method(:storeExpert),
          "void (string, map)"
        ),
        "options"       => getServerOptions,
        "ids"           => fun_ref(method(:valuesServTable), "list (map)"),
        "id2key"        => fun_ref(method(:Id2Key), "string (map, any)"),
        "fallback"      => {
          "init"    => fun_ref(method(:rowInit), "void (any, string)"),
          "store"   => fun_ref(method(:rowStore), "void (any, string)"),
          "summary" => fun_ref(method(:rowSummary), "string (any, string)")
        },
        "option_delete" => fun_ref(
          method(:rowDelete),
          "boolean (any, string)"
        ),
        "add_items"     => Builtins.maplist(
          Convert.convert(
            getServerOptions,
            :from => "map",
            :to   => "map <string, any>"
          )
        ) { |k1, v1| k1 },
        "help"          => Ops.get_string(@HELPS, "server_table", "")
      }
    ),
    # table with all files from /etc/slp.reg.d/
    "regedit_table"   => TablePopup.CreateTableDescr(
      {
        "add_delete_buttons" => true,
        "up_down_buttons"    => false,
        "unique_keys"        => false
      },
      {
        "init"          => fun_ref(
          method(:initRegEditExpert),
          "void (string)"
        ),
        "store"         => fun_ref(
          method(:storeRegEdit),
          "void (string, map)"
        ),
        "options"       => getRegEditOptions,
        "ids"           => fun_ref(method(:valuesRegFile), "list (map)"),
        "id2key"        => fun_ref(
          method(:Id2RegEditKey),
          "string (map, any)"
        ),
        "fallback"      => {
          "init"    => fun_ref(
            method(:rowRegEditInit),
            "void (any, string)"
          ),
          "store"   => fun_ref(
            method(:rowRegEditStore),
            "void (any, string)"
          ),
          "summary" => fun_ref(
            method(:rowRegEditSummary),
            "string (any, string)"
          )
        },
        "option_delete" => fun_ref(
          method(:rowRegEditDelete),
          "boolean (any, string)"
        ),
        "add_items"     => Builtins.maplist(
          Convert.convert(
            getRegEditOptions,
            :from => "map",
            :to   => "map <string, any>"
          )
        ) { |k1, v1| k1 }
      }
    ),
    # parameters from given reg.d file
    "reg_table"       => TablePopup.CreateTableDescr(
      {
        "add_delete_buttons" => true,
        "up_down_buttons"    => false,
        "unique_keys"        => false
      },
      {
        "init"          => fun_ref(method(:initReg), "void (string)"),
        "id2key"        => fun_ref(method(:Id2RegKey), "string (map, any)"),
        "ids"           => fun_ref(method(:valuesRegTable), "list (map)"),
        "option_delete" => fun_ref(
          method(:deleteReg),
          "boolean (any, string)"
        ),
        "fallback"      => {
          "summary" => fun_ref(
            method(:rowRegSummary),
            "string (any, string)"
          )
        },
        "help"          => Ops.get_string(@HELPS, "reg_files", ""),
        "handle"        => fun_ref(
          method(:handleRegTable),
          "symbol (string, map)"
        )
      }
    )
  }
  # description map for tabs in overview dialog
  @tabs_descr = {
    "general"        => {
      "header"       => _("Global SLP Configuration"),
      "contents"     => VBox(
        VStretch(),
        HBox(
          HStretch(),
          HSpacing(1),
          VBox(
            "auto_start_up",
            VSpacing(2),
            "firewall",
            VSpacing(2),
            "view_log",
            VSpacing(2)
          ),
          HSpacing(1),
          HStretch()
        ),
        VStretch()
      ),
      "widget_names" => ["auto_start_up", "firewall", "view_log"]
    },
    "server"         => {
      "header"       => _("SLP Server Configuration"),
      "contents"     => VBox(
        VStretch(),
        HBox(
          HStretch(),
          HSpacing(1),
          VBox("server_settings", VSpacing(2), "expert", VSpacing(2)),
          HSpacing(1),
          HStretch()
        ),
        VStretch()
      ),
      "widget_names" => ["server_settings", "expert"]
    },
    "server_details" => {
      "header"       => _("Server Details"),
      "contents"     => VBox(
        VStretch(),
        HBox(
          HStretch(),
          HSpacing(1),
          VBox("server_table", VSpacing(2)),
          HStretch(),
          HSpacing(1)
        ),
        VStretch()
      ),
      "widget_names" => ["server_table"]
    },
    "static"         => {
      "header"       => _("Static Configuration Files"),
      "contents"     => VBox("reg_table"),
      "widget_names" => ["reg_table"]
    }
  }
end

- (Object) initReg(key)



605
606
607
608
609
610
611
# File '../../src/include/slp-server/dialogs.rb', line 605

def initReg(key)
  @keys = []
  @reg_file = []
  TablePopup.TableInit(CWM.GetProcessedWidget, key)

  nil
end

- (Object) initRegEditExpert(key)



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File '../../src/include/slp-server/dialogs.rb', line 416

def initRegEditExpert(key)
  count = 0
  Builtins.foreach(SlpServer.reg_files) do |s|
    if Ops.get_string(s, "name", "") == @currentRegFile
      Builtins.foreach(Ops.get_list(s, "value", [])) do |row|
        @reg_file = Builtins.add(
          @reg_file,
          {
            Builtins.tostring(count) => {
              "KEY"   => Ops.get_string(row, "name", ""),
              "VALUE" => Ops.get_string(row, "value", "")
            }
          }
        )
        count = Ops.add(count, 1)
      end
    end
  end
  TablePopup.TableInit(CWM.GetProcessedWidget, key)

  nil
end

- (Object) initServerSettings(key)



783
784
785
786
787
788
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
# File '../../src/include/slp-server/dialogs.rb', line 783

def initServerSettings(key)
  mode = nil
  @keys = []
  UI.ChangeWidget(
    Id(:ip),
    :Value,
    String.CutBlanks(
      Ops.get_string(SlpServer.slp_config, "net.slp.DAAddresses", "")
    )
  )
  UI.ChangeWidget(
    Id(:scope),
    :Value,
    Ops.get_string(SlpServer.slp_config, "net.slp.useScopes", "")
  )
  if Ops.get_string(SlpServer.slp_config, "net.slp.isDA", "false") == "true"
    mode = :da_server
  elsif Ops.get_string(
      SlpServer.slp_config,
      "net.slp.isBroadcastOnly",
      "false"
    ) == "true"
    mode = :bc
  elsif Ops.greater_than(
      Builtins.size(
        Builtins.deletechars(
          Ops.get_string(SlpServer.slp_config, "net.slp.DAAddresses", ""),
          " "
        )
      ),
      0
    )
    mode = :da
  else
    mode = :mc
  end
  UI.ChangeWidget(Id(:resp), :CurrentButton, mode)
  changeResponseTo(mode)

  nil
end

- (Object) OverviewDialog

Overview dialog

Returns:

  • dialog result



880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File '../../src/include/slp-server/dialogs.rb', line 880

def OverviewDialog
  # SlpServer overview dialog caption
  caption = _("SLP Server Overview")

  widget_descr = {
    "tab" => CWMTab.CreateWidget(
      {
        "tab_order"    => ["general", "server", "static"],
        "tabs"         => @tabs_descr,
        "widget_descr" => @widgets,
        "initial_tab"  => @current_tab,
        "tab_help"     => _("<h1>SLP Server</h1>")
      }
    )
  }
  contents = VBox("tab")

  w = CWM.CreateWidgets(
    ["tab"],
    Convert.convert(
      widget_descr,
      :from => "map",
      :to   => "map <string, map <string, any>>"
    )
  )
  help = CWM.MergeHelps(w)
  contents = CWM.PrepareDialog(contents, w)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.NextButton,
    Label.FinishButton
  )
  Wizard.HideBackButton

  ret = CWM.Run(
    w,
    { :abort => fun_ref(method(:ReallyAbort), "boolean ()") }
  )
  ret
end

- (Object) rowDelete(opt_id, opt_key)



358
359
360
361
362
# File '../../src/include/slp-server/dialogs.rb', line 358

def rowDelete(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  Ops.set(@copy_config, opt_key, nil)
  true
end

- (Object) rowInit(option_id, option_type)



334
335
336
337
338
339
340
341
342
343
# File '../../src/include/slp-server/dialogs.rb', line 334

def rowInit(option_id, option_type)
  option_id = deep_copy(option_id)
  UI.ChangeWidget(
    Id(option_type),
    :Value,
    Ops.get_string(@copy_config, option_type, "")
  )

  nil
end

- (Object) rowRegEditDelete(opt_id, opt_key)



594
595
596
597
598
599
600
601
602
603
604
# File '../../src/include/slp-server/dialogs.rb', line 594

def rowRegEditDelete(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  @reg_file = Builtins.maplist(@reg_file) do |s|
    if Builtins.haskey(s, opt_id)
      Ops.set(s, [Builtins.tostring(opt_id), "VALUE"], "")
      Ops.set(s, [Builtins.tostring(opt_id), "KEY"], "")
    end
    deep_copy(s)
  end
  true
end

- (Object) rowRegEditInit(option_id, option_type)



537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File '../../src/include/slp-server/dialogs.rb', line 537

def rowRegEditInit(option_id, option_type)
  option_id = deep_copy(option_id)
  ret = ""
  Builtins.foreach(@reg_file) do |row|
    if Builtins.haskey(row, option_id)
      ret = Ops.get_string(
        Ops.get(@reg_file, Builtins.tointeger(option_id)),
        [Builtins.tostring(option_id), "VALUE"],
        ""
      )
    end
  end if option_id != nil
  UI.ChangeWidget(Id(option_type), :Value, ret)

  nil
end

- (Object) rowRegEditStore(option_id, option_type)



553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File '../../src/include/slp-server/dialogs.rb', line 553

def rowRegEditStore(option_id, option_type)
  option_id = deep_copy(option_id)
  if option_id != nil
    @reg_file = Builtins.maplist(@reg_file) do |s|
      if Builtins.haskey(s, option_id)
        Ops.set(
          s,
          [Builtins.tostring(option_id), "VALUE"],
          UI.QueryWidget(Id(option_type), :Value)
        )
      end
      deep_copy(s)
    end
  else
    @reg_file = Builtins.add(
      @reg_file,
      {
        Builtins.tostring(Builtins.size(@reg_file)) => {
          "KEY"   => option_type,
          "VALUE" => UI.QueryWidget(Id(option_type), :Value)
        }
      }
    )
  end

  nil
end

- (Object) rowRegEditSummary(option_id, option_type)



580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File '../../src/include/slp-server/dialogs.rb', line 580

def rowRegEditSummary(option_id, option_type)
  option_id = deep_copy(option_id)
  ret = ""
  Builtins.foreach(@reg_file) do |row|
    if Builtins.haskey(row, option_id)
      ret = Ops.get_string(
        Ops.get(@reg_file, Builtins.tointeger(option_id)),
        [Builtins.tostring(option_id), "VALUE"],
        ""
      )
    end
  end
  ret
end

- (Object) rowRegSummary(option_id, option_type)



639
640
641
642
# File '../../src/include/slp-server/dialogs.rb', line 639

def rowRegSummary(option_id, option_type)
  option_id = deep_copy(option_id)
  Ops.get_string(@reg_files_pkg, option_type, "")
end

- (Object) rowStore(option_id, option_type)



348
349
350
351
352
353
354
355
356
357
# File '../../src/include/slp-server/dialogs.rb', line 348

def rowStore(option_id, option_type)
  option_id = deep_copy(option_id)
  Ops.set(
    @copy_config,
    option_type,
    Convert.to_string(UI.QueryWidget(Id(option_type), :Value))
  )

  nil
end

- (Object) rowSummary(option_id, option_type)



344
345
346
347
# File '../../src/include/slp-server/dialogs.rb', line 344

def rowSummary(option_id, option_type)
  option_id = deep_copy(option_id)
  Ops.get_string(@copy_config, option_type, "")
end

- (Object) storeExpert(key, event)



314
315
316
317
318
319
320
# File '../../src/include/slp-server/dialogs.rb', line 314

def storeExpert(key, event)
  event = deep_copy(event)
  SlpServer.slp_config = deep_copy(@copy_config)
  @keys = []

  nil
end

- (Object) storeRegEdit(key, event)



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
# File '../../src/include/slp-server/dialogs.rb', line 438

def storeRegEdit(key, event)
  event = deep_copy(event)
  SlpServer.reg_files = Builtins.maplist(SlpServer.reg_files) do |file|
    if Ops.get_string(file, "name", "") == @currentRegFile
      count = 0
      Ops.set(
        file,
        "value",
        Builtins.maplist(Ops.get_list(file, "value", [])) do |line|
          Ops.set(
            line,
            "value",
            Ops.get_string(
              Ops.get(@reg_file, count),
              [Builtins.tostring(count), "VALUE"],
              ""
            )
          )
          Ops.set(
            line,
            "name",
            Ops.get_string(
              Ops.get(@reg_file, count),
              [Builtins.tostring(count), "KEY"],
              ""
            )
          )
          count = Ops.add(count, 1)
          deep_copy(line)
        end
      )

      while Ops.less_than(count, Builtins.size(@reg_file))
        Ops.set(
          file,
          "value",
          Builtins.add(
            Ops.get_list(file, "value", []),
            {
              "name"    => Ops.get_string(
                Ops.get(@reg_file, count),
                [Builtins.tostring(count), "KEY"],
                ""
              ),
              "value"   => Ops.get_string(
                Ops.get(@reg_file, count),
                [Builtins.tostring(count), "VALUE"],
                ""
              ),
              "type"    => 1,
              "kind"    => "value",
              "comment" => ""
            }
          )
        )
        count = Ops.add(count, 1)
      end
    end
    deep_copy(file)
  end

  nil
end

- (Object) storeServerSettings(option_id, option_map)



831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File '../../src/include/slp-server/dialogs.rb', line 831

def storeServerSettings(option_id, option_map)
  option_map = deep_copy(option_map)
  Ops.set(
    SlpServer.slp_config,
    "net.slp.useScopes",
    UI.QueryWidget(Id(:scope), :Value)
  )
  Ops.set(
    SlpServer.slp_config,
    "net.slp.DAAddresses",
    UI.QueryWidget(Id(:ip), :Value)
  )

  nil
end

- (Object) validateServerSettings(key, event)



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File '../../src/include/slp-server/dialogs.rb', line 846

def validateServerSettings(key, event)
  event = deep_copy(event)
  if UI.QueryWidget(Id(:resp), :CurrentButton) == :da
    ip_valid = true
    if Convert.to_string(UI.QueryWidget(Id(:ip), :Value)) == ""
      ip_valid = false
    end
    Builtins.foreach(
      Builtins.splitstring(
        Convert.to_string(UI.QueryWidget(Id(:ip), :Value)),
        ","
      )
    ) do |ip|
      if !Address.Check4(String.CutBlanks(ip)) &&
          !Address.Check6(String.CutBlanks(ip))
        ip_valid = false
      end
    end
    if !ip_valid
      Popup.Error(_("Scope and IP address must be inserted."))
      return false
    end
  end
  if UI.QueryWidget(Id(:resp), :CurrentButton) == :mc
    if UI.QueryWidget(Id(:scope), :Value) == ""
      Popup.Error(_("Scope must be inserted."))
      return false
    end
  end
  true
end

- (Object) valuesRegFile(descr)



504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File '../../src/include/slp-server/dialogs.rb', line 504

def valuesRegFile(descr)
  descr = deep_copy(descr)
  @keys = []
  Builtins.foreach(@reg_file) do |row|
    Builtins.foreach(
      Convert.convert(
        row,
        :from => "map <string, any>",
        :to   => "map <string, map <string, any>>"
      )
    ) do |key, value|
      if Ops.get_string(value, "KEY", "") != ""
        @keys = Builtins.add(@keys, key)
      end
    end
  end
  deep_copy(@keys)
end

- (Object) valuesRegTable(descr)



617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File '../../src/include/slp-server/dialogs.rb', line 617

def valuesRegTable(descr)
  descr = deep_copy(descr)
  if Builtins.size(@keys) == 0
    @keys = Builtins.maplist(SlpServer.reg_files) do |file|
      next Ops.get_string(file, "name", "") if Ops.get(file, "value") != nil
    end

    @keys = Builtins.filter(@keys) { |file| file != nil }

    Builtins.foreach(@keys) do |f|
      res = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), Ops.add("rpm -qf ", f))
      )
      if Ops.get_integer(res, "exit", 0) == 1
        Ops.set(@reg_files_pkg, f, "")
      else
        Ops.set(@reg_files_pkg, f, Ops.get_string(res, "stdout", ""))
      end
    end
  end
  deep_copy(@keys)
end

- (Object) valuesServTable(descr)



321
322
323
324
325
326
327
328
# File '../../src/include/slp-server/dialogs.rb', line 321

def valuesServTable(descr)
  descr = deep_copy(descr)
  @keys = []
  Builtins.foreach(@copy_config) do |k1, v1|
    @keys = Builtins.add(@keys, k1) if v1 != nil
  end
  deep_copy(@keys)
end