Class List Method List File List

# Module: Yast::SambaServerDialogsItemsInclude

Defined in:
  ../../src/include/samba-server/dialogs-items.rb

## Instance Method Summary (collapse)

- - (Object) AddPassdbBackend
- - (Object) GlobalSettingsContents(descr)
- - (Object) GlobalSettingsEntryDelete(opt_id, opt_key)
- - (Object) GlobalSettingsPopupInit(opt_id, opt_key)
- - (Object) GlobalSettingsPopupStore(opt_id, opt_key)
- - (Object) GlobalSettingsSummary(opt_id, opt_key)
- - (Object) handlePassdb(key, event_descr)
- - (Object) initialize_samba_server_dialogs_items(include_target)
- - (Object) initPassdb(key)
- - (Object) PassdbEditContents(descr)
- - (Object) PassdbEditOptionInit(opt_id, opt_key)
- - (Object) PassdbEditOptionStore(opt_id, opt_key)
- - (Object) PassdbEditOptionSummary(opt_id, opt_key)
- - (Object) PassdbEditOptionValidate(key, event_descr)
- - (Object) PassdbEntryDelete(opt_id, opt_key)
- - (Object) PassdbId2Key(desc, id)
- - (Object) PassdbOptionMove(opt_id, opt_key, direction)
- - (Object) RedrawPassdbEditButtons
- - (Object) ShareEditContents(descr)
- - (Object) ShareEditEntryDelete(opt_id, opt_key)
- - (Object) ShareEditPopupInit(opt_id, opt_key)
- - (Object) ShareEditPopupStore(opt_id, opt_key)
- - (Object) ShareEditSummary(opt_id, opt_key)
- - (Object) ShareHandleFun(key, event_descr)
- - (Object) ShareInitFun(key)
- - (Object) SharePathWarning(p)
- - (Object) SomeBackendsAreInUse
- - (Object) storePassdb(key, event)
- - (Object) ValidateLDAPURL(opt_id, opt_key, event_descr)
- - (Object) ValidateSharePath(opt_id, opt_key, event_descr)

## Instance Method Details

### - (`Object`) AddPassdbBackend

    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
    604
    605
    606
    607
    608
    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
    # File '../../src/include/samba-server/dialogs-items.rb', line 578

    def AddPassdbBackend
      UI.OpenDialog(
        VBox(
          # translators: frame text when adding a passdb backend
          Frame(
            _("Back-End Type"),
            RadioButtonGroup(
              Id(:types),
              VBox(
                # translators: passdb backend radio button
                Left(
                  RadioButton(
                    Id("smbpasswd"),
                    Opt(:notify),
                    _("smbpasswd File")
                  )
                ), # Unknown passdb backend
                #		    // translators: passdb backend radio button
                #		    `Left (`RadioButton ( `id("mysql"), `opt (`notify),_("MySQL Database") ) )
                # translators: passdb backend radio button
                Left(RadioButton(Id("ldapsam"), Opt(:notify), _("LDAP"))),
                # translators: passdb backend radio button
                Left(RadioButton(Id("tdbsam"), Opt(:notify), _("TDB Database")))
              )
            )
          ),
          # translators: textentry label to enter details for the selected passdb backend
          TextEntry(Id("details"), _("&Details")),
          HBox(
            PushButton(Id("add"), Opt(:default), Label.AddButton),
            PushButton(Id("cancel"), Label.CancelButton)
          )
        )
      )
      begin
        ret = UI.UserInput
        if Builtins.contains(["smbpasswd", "ldapsam", "tdbsam", "mysql"], ret)
          # prefill a hint, if details empty
          details = Convert.to_string(UI.QueryWidget(Id("details"), :Value))
          if Builtins.size(details) == 0
            if ret == "ldapsam"
              Yast.import "Ldap"
              # ask LDAP client for the value
              server = Ldap.server

              # ensure to take only the first one
              servers = Builtins.splitstring(server, " ")
              UI.ChangeWidget(
                Id("details"),
                :Value,
                Ops.add("ldap://", Ops.get(servers, 0, "localhost"))
              )
            end
          end

          next
        elsif ret == "add"
          # check: all types except smbpasswd must get detailed info
          type = Convert.to_string(UI.QueryWidget(Id(:types), :CurrentButton))
          details = Convert.to_string(UI.QueryWidget(Id("details"), :Value))
          if Builtins.size(details) != 0
            details = Ops.add(":", details)
          else
            details = ""
          end

          if type == "mysql" && Builtins.size(details) == 0
            # translators: error message, if the MySQL backend
            # is selected, but no details are entered
            Popup.Error(
              _(
                "An identifier must be provided\n" +
                  "in details \n" +
                  "for the MySQL passdb back-end.\n" +
                  "\n" +
                  "Consult the Samba HOWTO collection for\n" +
                  "further information.\n"
              )
            )
            next
          # validate LDAP
          elsif type == "ldapsam" && Ops.greater_than(Builtins.size(details), 0)
            # fill in empty params to keep interpreter happy
            next if !ValidateLDAPURL(nil, "details", nil)
          end

          # add the value
          id = Builtins.sformat("%1", @max_id)
          @max_id = Ops.add(@max_id, 1)
          @passdb_backends = Builtins.add(
            @passdb_backends,
            id,
            Ops.add(type, details)
          )
          @passdb_order = Builtins.add(@passdb_order, id)
        end
        break
      end while true

      UI.CloseDialog

      nil
    end

### - (`Object`) GlobalSettingsContents(descr)

    398
    399
    400
    401
    # File '../../src/include/samba-server/dialogs-items.rb', line 398

    def GlobalSettingsContents(descr)
      descr = deep_copy(descr)
      SambaConfig.GlobalKeys
    end

### - (`Object`) GlobalSettingsEntryDelete(opt_id, opt_key)

    402
    403
    404
    405
    406
    407
    408
    # File '../../src/include/samba-server/dialogs-items.rb', line 402

    def GlobalSettingsEntryDelete(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      # message popup
      return false if !Popup.YesNo(_("Delete the selected entry?"))
      SambaConfig.GlobalSetStr(opt_key, nil)
      true
    end

### - (`Object`) GlobalSettingsPopupInit(opt_id, opt_key)

    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    # File '../../src/include/samba-server/dialogs-items.rb', line 409

    def GlobalSettingsPopupInit(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      if opt_id != nil
        val = UI.QueryWidget(Id(opt_key), :Value)
        if Ops.is_boolean?(val)
          UI.ChangeWidget(
            Id(opt_key),
            :Value,
            SambaConfig.GlobalGetTruth(opt_key, nil)
          )
        else
          UI.ChangeWidget(
            Id(opt_key),
            :Value,
            SambaConfig.GlobalGetStr(opt_key, nil)
          )
        end
      end
      UI.SetFocus(Id(opt_key))

      nil
    end

### - (`Object`) GlobalSettingsPopupStore(opt_id, opt_key)

    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    # File '../../src/include/samba-server/dialogs-items.rb', line 431

    def GlobalSettingsPopupStore(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      val = UI.QueryWidget(Id(opt_key), :Value)
      if Ops.is_boolean?(val)
        SambaConfig.GlobalSetTruth(opt_key, Convert.to_boolean(val))
      else
        SambaConfig.GlobalSetStr(opt_key, Convert.to_string(val))
      end

      nil
    end

### - (`Object`) GlobalSettingsSummary(opt_id, opt_key)

    442
    443
    444
    445
    # File '../../src/include/samba-server/dialogs-items.rb', line 442

    def GlobalSettingsSummary(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      SambaConfig.GlobalGetStr(opt_key, "")
    end

### - (`Object`) handlePassdb(key, event_descr)

    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    # File '../../src/include/samba-server/dialogs-items.rb', line 700

    def handlePassdb(key, event_descr)
      event_descr = deep_copy(event_descr)
      if Ops.get(event_descr, "ID") == :_tp_add
        AddPassdbBackend()
        TablePopup.TableInit(Ops.get_map(@xx_widgets, "passdb_edit", {}), key)
        RedrawPassdbEditButtons()
        # continue
        return nil
      end

      if Ops.get(event_descr, "ID") == :back
        @passdb_backends = nil
        return nil
      end

      ret = TablePopup.TableHandle(
        Ops.get_map(@xx_widgets, "passdb_edit", {}),
        key,
        event_descr
      )
      RedrawPassdbEditButtons()
      ret
    end

### - (`Object`) initialize_samba_server_dialogs_items(include_target)

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

    def initialize_samba_server_dialogs_items(include_target)
      Yast.import "UI"

      textdomain "samba-server"

      Yast.import "Label"
      Yast.import "Popup"
      Yast.import "LogView"
      Yast.import "TablePopup"
      Yast.import "FileUtils"
      Yast.import "Report"

      Yast.import "SambaServer"
      Yast.import "SambaConfig"
      Yast.import "SambaBackend"

      Yast.include include_target, "samba-server/helps.rb"
      Yast.include include_target, "samba-server/complex.rb"

      Yast.include include_target, "samba-server/samba-options-local.rb"
      Yast.include include_target, "samba-server/samba-options-global.rb"

      #//////////////////////////////////
      @shareswidget = TablePopup.CreateTableDescr(
        {
          "add_delete_buttons" => true,
          "up_down_buttons"    => false,
          "unique_keys"        => true
        },
        {
          "init"          => fun_ref(method(:ShareInitFun), "void (string)"),
          "handle"        => fun_ref(
            method(:ShareHandleFun),
            "symbol (string, map)"
          ),
          "options"       => @local_option_widgets,
          "ids"           => fun_ref(method(:ShareEditContents), "list (map)"),
          "fallback"      => {
            "init"    => fun_ref(
              method(:ShareEditPopupInit),
              "void (any, string)"
            ),
            "store"   => fun_ref(
              method(:ShareEditPopupStore),
              "void (any, string)"
            ),
            "summary" => fun_ref(
              method(:ShareEditSummary),
              "string (any, string)"
            )
          },
          "option_delete" => fun_ref(
            method(:ShareEditEntryDelete),
            "boolean (any, string)"
          ),
          "add_items"     => Builtins.maplist(@local_option_widgets) do |key, values|
            key
          end,
          "help"          => Ops.get_string(@HELPS, "share_edit", "")
        }
      )

      @globalsettingswidget = TablePopup.CreateTableDescr(
        {
          "add_delete_buttons" => true,
          "up_down_buttons"    => false,
          "unique_keys"        => true
        },
        {
          "options"       => @global_option_widgets,
          "ids"           => fun_ref(
            method(:GlobalSettingsContents),
            "list (map)"
          ),
          "fallback"      => {
            "init"    => fun_ref(
              method(:GlobalSettingsPopupInit),
              "void (any, string)"
            ),
            "store"   => fun_ref(
              method(:GlobalSettingsPopupStore),
              "void (any, string)"
            ),
            "summary" => fun_ref(
              method(:GlobalSettingsSummary),
              "string (any, string)"
            )
          },
          "option_delete" => fun_ref(
            method(:GlobalSettingsEntryDelete),
            "boolean (any, string)"
          ),
          "add_items"     => Builtins.maplist(@global_option_widgets) do |key, values|
            key
          end,
          "help"          => Ops.get_string(@HELPS, "global_settings", "")
        }
      )

      @passdboptions =
        # MySQL will not be offered, unknown backend
        #    "mysql" : $[
        #        "table" : $[
        #	    // table entry description for MySQL-based SAM
        #           "label" : _("MySQL database"),
        #        ],
        #        "popup" : $[
        #         "widget" : `textentry,
        #        ],
        #    ],
        {
          "smbpasswd" => {
            "table" => {
              # table entry description for smbpasswd-based SAM
              "label" => _(
                "smbpasswd file"
              )
            },
            "popup" => { "widget" => :textentry }
          },
          "ldapsam"   => {
            "table" => {
              # table entry description for LDAP-based SAM
              "label" => _("LDAP")
            },
            "popup" => {
              "widget"            => :textentry,
              "validate_type"     => :function,
              "validate_function" => fun_ref(
                method(:ValidateLDAPURL),
                "boolean (any, string, map)"
              )
            }
          },
          "tdbsam"    => {
            "table" => {
              # table entry description for TDB-based SAM
              "label" => _(
                "TDB database"
              )
            },
            "popup" => { "widget" => :textentry }
          }
        }

      @passdbwidget = TablePopup.CreateTableDescr(
        {
          "add_delete_buttons" => true,
          "up_down_buttons"    => false,
          "unique_keys"        => false
        },
        {
          "init"              => fun_ref(method(:initPassdb), "void (string)"),
          "handle"            => fun_ref(
            method(:handlePassdb),
            "symbol (string, map)"
          ),
          "store"             => fun_ref(
            method(:storePassdb),
            "void (string, map)"
          ),
          "ids"               => fun_ref(
            method(:PassdbEditContents),
            "list (map)"
          ),
          "help"              => Ops.get_string(@HELPS, "passdb_edit", ""),
          "options"           => @passdboptions,
          "add_items"         => ["smbpasswd", "ldapsam", "tdbsam"],
          "add_unlisted"      => false,
          "id2key"            => fun_ref(
            method(:PassdbId2Key),
            "string (map, any)"
          ),
          "option_delete"     => fun_ref(
            method(:PassdbEntryDelete),
            "boolean (any, string)"
          ),
          "validate_type"     => :function,
          "validate_function" => fun_ref(
            method(:PassdbEditOptionValidate),
            "boolean (string, map)"
          ),
          # only one passdb backend is possible
          # "option_move" : PassdbOptionMove,
          "fallback"          => {
            "init"    => fun_ref(
              method(:PassdbEditOptionInit),
              "void (any, string)"
            ),
            "store"   => fun_ref(
              method(:PassdbEditOptionStore),
              "void (any, string)"
            ),
            "summary" => fun_ref(
              method(:PassdbEditOptionSummary),
              "string (any, string)"
            )
          }
        }
      )

      # Map of widgets for CWM
      @xx_widgets = {
        "share_edit"     => @shareswidget,
        "passdb_edit"    => @passdbwidget,
        "globalsettings" => @globalsettingswidget
      }

      # A share name do be editted in the Edit share dialog
      @shareToEdit = nil

      #************************************ passdb list table ***********************************

      @max_id = 0
      @passdb_backends = nil
      @passdb_order = []
    end

### - (`Object`) initPassdb(key)

    694
    695
    696
    697
    698
    699
    # File '../../src/include/samba-server/dialogs-items.rb', line 694

    def initPassdb(key)
      TablePopup.TableInit(Ops.get_map(@xx_widgets, "passdb_edit", {}), key)
      RedrawPassdbEditButtons()

      nil
    end

### - (`Object`) PassdbEditContents(descr)

    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    # File '../../src/include/samba-server/dialogs-items.rb', line 458

    def PassdbEditContents(descr)
      descr = deep_copy(descr)
      if @passdb_backends != nil
        # we are already initialized
        return deep_copy(@passdb_order)
      else
        l = SambaBackend.GetPassdbBackends
        ids = []
        @max_id = -1
        @passdb_backends = Builtins.listmap(l) do |backend|
          @max_id = Ops.add(@max_id, 1)
          s = Builtins.sformat("%1", @max_id)
          ids = Builtins.add(ids, s)
          { s => backend }
        end
        @max_id = Ops.add(@max_id, 1)
        @passdb_order = deep_copy(ids)
        return deep_copy(ids)
      end
    end

### - (`Object`) PassdbEditOptionInit(opt_id, opt_key)

    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    # File '../../src/include/samba-server/dialogs-items.rb', line 488

    def PassdbEditOptionInit(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      if opt_id != nil
        # not adding a new option
        UI.ChangeWidget(
          Id(opt_key),
          :Value,
          SambaBackend.GetLocation(
            Ops.get(@passdb_backends, Convert.to_string(opt_id), "")
          )
        )
      end
      UI.SetFocus(Id(opt_key))

      RedrawPassdbEditButtons()

      nil
    end

### - (`Object`) PassdbEditOptionStore(opt_id, opt_key)

    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
    536
    537
    538
    539
    540
    541
    542
    543
    # File '../../src/include/samba-server/dialogs-items.rb', line 506

    def PassdbEditOptionStore(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      details = Convert.to_string(UI.QueryWidget(Id(opt_key), :Value))
      # TODO: handle empty details

      if Builtins.size(details) != 0
        details = Ops.add(":", details)
      else
        details = ""
      end

      if opt_id != nil
        # update
        # take the SAM type from the old data and append the new details
        Ops.set(
          @passdb_backends,
          Convert.to_string(opt_id),
          Ops.add(
            SambaBackend.GetName(
              Ops.get(@passdb_backends, Convert.to_string(opt_id))
            ),
            details
          )
        )
      else
        # insert new
        id = Builtins.sformat("%1", @max_id)
        @max_id = Ops.add(@max_id, 1)
        @passdb_backends = Builtins.add(
          @passdb_backends,
          id,
          Ops.add(opt_key, details)
        )
        @passdb_order = Builtins.add(@passdb_order, id)
      end

      nil
    end

### - (`Object`) PassdbEditOptionSummary(opt_id, opt_key)

    544
    545
    546
    547
    548
    # File '../../src/include/samba-server/dialogs-items.rb', line 544

    def PassdbEditOptionSummary(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      option = Ops.get(@passdb_backends, Convert.to_string(opt_id), "")
      SambaBackend.GetLocation(option)
    end

### - (`Object`) PassdbEditOptionValidate(key, event_descr)

    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    # File '../../src/include/samba-server/dialogs-items.rb', line 478

    def PassdbEditOptionValidate(key, event_descr)
      event_descr = deep_copy(event_descr)
      if !SomeBackendsAreInUse()
        Report.Error(_("At least one backend must be specified."))

        return false
      end

      true
    end

### - (`Object`) PassdbEntryDelete(opt_id, opt_key)

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

    def PassdbEntryDelete(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      #	if (size (passdb_backends) == 1)
      #	{
      #	    // error message if user tries to delete the last passdb backend
      #	    Report::Error (_("At least one back-end must be specified.
      #
      #The back-end cannot be deleted.
      #"));
      #	    return false;
      #	}

      # message popup
      return false if !Popup.YesNo(_("Delete the selected back-end?"))

      id = Convert.to_string(opt_id)
      @passdb_backends = Builtins.filter(@passdb_backends) { |k, v| k != id }
      @passdb_order = Builtins.filter(@passdb_order) { |k| k != id }

      RedrawPassdbEditButtons()

      true
    end

### - (`Object`) PassdbId2Key(desc, id)

    549
    550
    551
    552
    553
    554
    # File '../../src/include/samba-server/dialogs-items.rb', line 549

    def PassdbId2Key(desc, id)
      desc = deep_copy(desc)
      id = deep_copy(id)
      s_id = Ops.get(@passdb_backends, Convert.to_string(id), "")
      SambaBackend.GetName(s_id)
    end

### - (`Object`) PassdbOptionMove(opt_id, opt_key, direction)

    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    # File '../../src/include/samba-server/dialogs-items.rb', line 681

    def PassdbOptionMove(opt_id, opt_key, direction)
      opt_id = deep_copy(opt_id)
      id = Convert.to_string(opt_id)

      @passdb_order = Builtins.sort(@passdb_order) do |left, right|
        res = direction == :down ?
          left == id ? false : true :
          right == id ? false : true
        res
      end
      initPassdb(opt_key)
      deep_copy(opt_id)
    end

### - (`Object`) RedrawPassdbEditButtons

    451
    452
    453
    454
    455
    456
    457
    # File '../../src/include/samba-server/dialogs-items.rb', line 451

    def RedrawPassdbEditButtons
      if UI.WidgetExists(Id(:_tp_add))
        UI.ChangeWidget(Id(:_tp_add), :Enabled, !SomeBackendsAreInUse())
      end

      nil
    end

### - (`Object`) ShareEditContents(descr)

    345
    346
    347
    348
    # File '../../src/include/samba-server/dialogs-items.rb', line 345

    def ShareEditContents(descr)
      descr = deep_copy(descr)
      SambaConfig.ShareKeys(@shareToEdit)
    end

### - (`Object`) ShareEditEntryDelete(opt_id, opt_key)

    349
    350
    351
    352
    353
    354
    355
    # File '../../src/include/samba-server/dialogs-items.rb', line 349

    def ShareEditEntryDelete(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      # message popup
      return false if !Popup.YesNo(_("Delete the selected entry?"))
      SambaConfig.ShareSetStr(@shareToEdit, opt_key, nil)
      true
    end

### - (`Object`) ShareEditPopupInit(opt_id, opt_key)

    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    # File '../../src/include/samba-server/dialogs-items.rb', line 356

    def ShareEditPopupInit(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      if opt_id != nil
        # not adding a new option
        val = UI.QueryWidget(Id(opt_key), :Value)
        if Ops.is_boolean?(val)
          UI.ChangeWidget(
            Id(opt_key),
            :Value,
            SambaConfig.ShareGetTruth(@shareToEdit, opt_key, nil)
          )
        else
          UI.ChangeWidget(
            Id(opt_key),
            :Value,
            SambaConfig.ShareGetStr(@shareToEdit, opt_key, nil)
          )
        end
      end
      UI.SetFocus(Id(opt_key))

      nil
    end

### - (`Object`) ShareEditPopupStore(opt_id, opt_key)

    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    # File '../../src/include/samba-server/dialogs-items.rb', line 379

    def ShareEditPopupStore(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      val = UI.QueryWidget(Id(opt_key), :Value)
      if Ops.is_boolean?(val)
        SambaConfig.ShareSetTruth(
          @shareToEdit,
          opt_key,
          Convert.to_boolean(val)
        )
      else
        SambaConfig.ShareSetStr(@shareToEdit, opt_key, Convert.to_string(val))
      end

      nil
    end

### - (`Object`) ShareEditSummary(opt_id, opt_key)

    394
    395
    396
    397
    # File '../../src/include/samba-server/dialogs-items.rb', line 394

    def ShareEditSummary(opt_id, opt_key)
      opt_id = deep_copy(opt_id)
      SambaConfig.ShareGetStr(@shareToEdit, opt_key, "")
    end

### - (`Object`) ShareHandleFun(key, event_descr)

    337
    338
    339
    340
    341
    342
    343
    344
    # File '../../src/include/samba-server/dialogs-items.rb', line 337

    def ShareHandleFun(key, event_descr)
      event_descr = deep_copy(event_descr)
      TablePopup.TableHandle(
        Ops.get_map(@xx_widgets, "share_edit", {}),
        key,
        event_descr
      )
    end

### - (`Object`) ShareInitFun(key)

    332
    333
    334
    335
    336
    # File '../../src/include/samba-server/dialogs-items.rb', line 332

    def ShareInitFun(key)
      TablePopup.TableInit(Ops.get_map(@xx_widgets, "share_edit", {}), key)

      nil
    end

### - (`Object`) SharePathWarning(p)

    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    # File '../../src/include/samba-server/dialogs-items.rb', line 309

    def SharePathWarning(p)
      text = nil

      if p == "/"
        text = @root_warning
      else
        text = Ops.get(@warnings, p) if Ops.get(@warnings, p) != nil
      end

      return Popup.ContinueCancel(text) if text != nil

      true
    end

### - (`Object`) SomeBackendsAreInUse

    447
    448
    449
    # File '../../src/include/samba-server/dialogs-items.rb', line 447

    def SomeBackendsAreInUse
      Ops.greater_than(Builtins.size(@passdb_backends), 0)
    end

### - (`Object`) storePassdb(key, event)

    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    # File '../../src/include/samba-server/dialogs-items.rb', line 723

    def storePassdb(key, event)
      event = deep_copy(event)
      res = Builtins.maplist(@passdb_order) do |id|
        Ops.get(@passdb_backends, id, "")
      end
      SambaBackend.SetPassdbBackends(res)
      @passdb_backends = nil # require a new initialization

      nil
    end

### - (`Object`) ValidateLDAPURL(opt_id, opt_key, event_descr)

    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/samba-server/dialogs-items.rb', line 252

    def ValidateLDAPURL(opt_id, opt_key, event_descr)
      opt_id = deep_copy(opt_id)
      event_descr = deep_copy(event_descr)
      Yast.import "URL"

      url = Convert.to_string(UI.QueryWidget(Id(opt_key), :Value))

      if Builtins.regexpmatch(url, "^[ \t]+")
        # TRANSLATORS: popup error
        Report.Error(_("Optional value must not begin with a space character."))
        return false
      end

      quotes_used = false

      # ldapsam:"ldap://ldap1.example.com ldap://ldap2.example.com"
      if Builtins.regexpmatch(url, "^\".*\"[ \t]*$")
        quotes_used = true
        url = Builtins.regexpsub(url, "^\"(.*)\"[ \t]*$", "\\1")
      end

      urls = Builtins.splitstring(url, " \t")
      urls = Builtins.filter(urls) { |url2| url2 != "" }

      if Ops.greater_than(Builtins.size(urls), 1) && !quotes_used
        # TRANSLATORS: popup error
        Report.Error(
          _("Multiple optional values for one backend must be quoted.")
        )
        return false
      end

      ret = true
      Builtins.foreach(urls) do |url2|
        next if ret != true
        if !URL.Check(url2)
          Builtins.y2error("Invalid url '%1'", url2)
          # TRANSLATORS: popup error, %1 is replaced with some URL
          Popup.Error(
            Builtins.sformat(_("The entered URL '%1' is invalid"), url2)
          )
          ret = false
        end
        u = URL.Parse(url2)
        if Ops.get(u, "scheme") != "ldap" && Ops.get(u, "scheme") != "ldaps"
          Builtins.y2error("Invalid url '%1'", url2)
          # TRANSLATORS: popup error, %1 is replaced with some URL
          Popup.Error(
            Builtins.sformat(_("The entered URL '%1' is invalid"), url2)
          )
          ret = false
        end
      end

      ret
    end

### - (`Object`) ValidateSharePath(opt_id, opt_key, event_descr)

    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    # File '../../src/include/samba-server/dialogs-items.rb', line 322

    def ValidateSharePath(opt_id, opt_key, event_descr)
      opt_id = deep_copy(opt_id)
      event_descr = deep_copy(event_descr)
      p = Convert.to_string(UI.QueryWidget(Id(opt_key), :Value))

      return false if !SharePathWarning(p)
      return false if !FileUtils.CheckAndCreatePath(p)

      true
    end