Class List Method List File List

# Module: Yast::MailWidgetsInclude

Defined in:
  ../../src/include/mail/widgets.rb

## Instance Method Summary (collapse)

- - (Object) check_mail_local_part(address)

  See RFC 2822, 3.4 But for now, nonempty, no-spaces.

- - (Array) Choices_delivery_mode

  Of choides for a combo box.

- - (Array) Choices_local_user

  Of choides for a combo box.

- - (Array) Choices_protocol

  Of choides for a combo box.

- - (Object) Get_delivery_mode

  A variable to be used by a widget.

- - (Object) Get_fm_local_user

  A variable to be used by a widget.

- - (Object) Get_fm_password

  A variable to be used by a widget.

- - (Object) Get_fm_protocol

  A variable to be used by a widget.

- - (Object) Get_fm_remote_user

  A variable to be used by a widget.

- - (Object) Get_fm_server

  A variable to be used by a widget.

- - (Object) Get_foo

  (sample).

- - (Object) Get_from_header

  A variable to be used by a widget.

- - (Object) Get_listen_remote

  A variable to be used by a widget.

- - (Object) Get_local_domains

  A variable to be used by a widget.

- - (Object) Get_outgoing_mail_server

  A variable to be used by a widget.

- - (Object) Get_root_alias

  A variable to be used by a widget.

- - (Object) Get_use_amavis

  A variable to be used by a widget.

- - (Object) Get_use_dkim

  A variable to be used by a widget.

- - (Object) GetLocalUsers

  Read user names from passwd.

- - (Object) initialize_mail_widgets(include_target)
- - (Object) listToString(alist)

  Formats a list for a TextEntry, separating the elements by “, ”.

- - (Object) Set_delivery_mode(id)

  Set a variable acording to widget value.

- - (Object) Set_fm_local_user(id)

  Set a variable acording to widget value.

- - (Object) Set_fm_password(id)

  Set a variable acording to widget value.

- - (Object) Set_fm_protocol(id)

  Set a variable acording to widget value.

- - (Object) Set_fm_remote_user(id)

  Set a variable acording to widget value.

- - (Object) Set_fm_server(id)

  Set a variable acording to widget value.

- - (Object) Set_foo(id)

  (sample) Set a variable acording to widget value.

- - (Object) Set_from_header(id)

  Set a variable acording to widget value.

- - (Object) Set_listen_remote(id)

  Set a variable acording to widget value.

- - (Object) Set_local_domains(id)

  Set a variable acording to widget value.

- - (Object) Set_outgoing_mail_server(id)

  Set a variable acording to widget value.

- - (Object) Set_root_alias(id)

  Set a variable acording to widget value.

- - (Object) Set_use_amavis(id)

  Set a variable acording to widget value.

- - (Object) Set_use_dkim(id)

  Set a variable acording to widget value.

- - (Object) stringToList(astring)

  Splits a TextEntry string into a list of strings separated by spaces, commas or semicolons.

- - (Object) Validate_delivery_mode(id)

  Validate widget value.

- - (Object) Validate_fm_local_user(id)

  Validate widget value.

- - (Object) Validate_fm_remote_user(id)

  also used for smtp_auth user Validate widget value.

- - (Object) Validate_fm_server(id)

  also used for smtp_auth server Validate widget value.

- - (Object) Validate_foo(id)

  (sample) Validate widget value.

- - (Object) Validate_from_header(id)
- - (Object) Validate_local_domains(id)

  Validate widget value.

- - (Object) Validate_outgoing_mail_server(id)

  Validate widget value.

- - (Object) Validate_root_alias(id)

  Validate widget value.

## Instance Method Details

### - (`Object`) check_mail_local_part(address)

See RFC 2822, 3.4 But for now, nonempty, no-spaces.

Parameters:

- address (`String`) —

  an address to check

Returns:

- valid?

    325
    326
    327
    # File '../../src/include/mail/widgets.rb', line 325

    def check_mail_local_part(address)
      address != "" && Builtins.findfirstof(address, " ") == nil
    end

### - (`Array`) Choices_delivery_mode

Returns of choides for a combo box

Returns:

- (`Array`) —

  of choides for a combo box

    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    # File '../../src/include/mail/widgets.rb', line 856

    def Choices_delivery_mode
      # TODO: should check whether cyrus-imapd is installed.
      # And show the choice only if it is.
      # But config.postfix falls back to local if it's not, so OK
      [
        # combo box choice:
        # deliver mail normally
        Item(Id(:dm_local), _("Directly")),
        # combo box choice:
        # deliver mail through procmail
        Item(Id(:dm_procmail), _("Through procmail")),
        # combo box choice:
        # deliver mail to cyrus-imapd using LMTP
        Item(Id(:dm_cyrus), _("To Cyrus IMAP Server"))
      ]
    end

### - (`Array`) Choices_local_user

Returns of choides for a combo box

Returns:

- (`Array`) —

  of choides for a combo box

    851
    852
    853
    # File '../../src/include/mail/widgets.rb', line 851

    def Choices_local_user
      GetLocalUsers()
    end

### - (`Array`) Choices_protocol

Returns of choides for a combo box

Returns:

- (`Array`) —

  of choides for a combo box

    846
    847
    848
    # File '../../src/include/mail/widgets.rb', line 846

    def Choices_protocol
      deep_copy(Mail.protocol_choices)
    end

### - (`Object`) Get_delivery_mode

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    786
    787
    788
    789
    790
    791
    792
    793
    794
    # File '../../src/include/mail/widgets.rb', line 786

    def Get_delivery_mode
      scr2ui = {
        :local    => :dm_local,
        :procmail => :dm_procmail,
        :cyrus    => :dm_cyrus
      }
      val = Ops.get_symbol(scr2ui, Mail.postfix_mda, :dm_local)
      val
    end

### - (`Object`) Get_fm_local_user

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    725
    726
    727
    # File '../../src/include/mail/widgets.rb', line 725

    def Get_fm_local_user
      Ops.get_string(@fetchmail_item, "local_user", "")
    end

### - (`Object`) Get_fm_password

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    708
    709
    710
    # File '../../src/include/mail/widgets.rb', line 708

    def Get_fm_password
      Ops.get_string(@fetchmail_item, "password", "")
    end

### - (`Object`) Get_fm_protocol

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    661
    662
    663
    # File '../../src/include/mail/widgets.rb', line 661

    def Get_fm_protocol
      Ops.get_string(@fetchmail_item, "protocol", "AUTO")
    end

### - (`Object`) Get_fm_remote_user

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    677
    678
    679
    # File '../../src/include/mail/widgets.rb', line 677

    def Get_fm_remote_user
      Ops.get_string(@fetchmail_item, "remote_user", "")
    end

### - (`Object`) Get_fm_server

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    629
    630
    631
    # File '../../src/include/mail/widgets.rb', line 629

    def Get_fm_server
      Ops.get_string(@fetchmail_item, "server", "")
    end

### - (`Object`) Get_foo

(sample)

Returns:

- a variable to be used by a widget

    436
    437
    438
    # File '../../src/include/mail/widgets.rb', line 436

    def Get_foo
      Ops.get_string(@fetchmail_item, "protocol", "")
    end

### - (`Object`) Get_from_header

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    516
    517
    518
    # File '../../src/include/mail/widgets.rb', line 516

    def Get_from_header
      Mail.from_header
    end

### - (`Object`) Get_listen_remote

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    583
    584
    585
    # File '../../src/include/mail/widgets.rb', line 583

    def Get_listen_remote
      Mail.listen_remote
    end

### - (`Object`) Get_local_domains

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    541
    542
    543
    # File '../../src/include/mail/widgets.rb', line 541

    def Get_local_domains
      listToString(Mail.local_domains)
    end

### - (`Object`) Get_outgoing_mail_server

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    469
    470
    471
    # File '../../src/include/mail/widgets.rb', line 469

    def Get_outgoing_mail_server
      Mail.outgoing_mail_server
    end

### - (`Object`) Get_root_alias

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    756
    757
    758
    # File '../../src/include/mail/widgets.rb', line 756

    def Get_root_alias
      MailAliases.root_alias
    end

### - (`Object`) Get_use_amavis

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    598
    599
    600
    # File '../../src/include/mail/widgets.rb', line 598

    def Get_use_amavis
      Mail.use_amavis
    end

### - (`Object`) Get_use_dkim

Returns a variable to be used by a widget

Returns:

- a variable to be used by a widget

    613
    614
    615
    # File '../../src/include/mail/widgets.rb', line 613

    def Get_use_dkim
      Mail.use_dkim
    end

### - (`Object`) GetLocalUsers

Read user names from passwd. It does not get the NIS entries, that's why one combo is editable. "+" is filtered out.

Returns:

- user name list

    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    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/mail/widgets.rb', line 333

    def GetLocalUsers
      if @local_users == nil
        # initialize the list
        Yast.import "Users"
        Yast.import "UsersCache"
        Yast.import "Ldap"

        UI.OpenDialog(
          VBox(
            # LogView label. take a string from users?
            LogView(
              Id(:progress),
              _("Reading the &User List"),
              # visible, max
              4,
              10
            ),
            VSpacing(1)
          )
        )

        Users.SetGUI(false)
        @local_users = []

        UI.ChangeWidget(
          Id(:progress),
          :LastLine,
          # LogView progress line
          _("Local users") + "\n"
        )
        Users.Read
        @local_users = Builtins.flatten(
          [
            @local_users,
            UsersCache.GetUsernames("local"),
            UsersCache.GetUsernames("system")
          ]
        )

        if Users.LDAPAvailable
          UI.ChangeWidget(
            Id(:progress),
            :LastLine,
            # LogView progress line
            _("LDAP users") + "\n"
          )

          if Users.LDAPNotRead
            # open the popup that asks for password (or anonymous access)
            #if (Ldap::bind_pass == nil)
            #    Ldap::SetBindPassword (Ldap::GetLDAPPassword (true));
            # alternatively, force anonymous access:
            Ldap.SetAnonymous(true)
            Users.ReadNewSet("ldap")
          end
          @local_users = Builtins.flatten(
            [@local_users, UsersCache.GetUsernames("ldap")]
          )
        end

        if Users.NISAvailable
          UI.ChangeWidget(
            Id(:progress),
            :LastLine,
            # LogView progress line
            _("NIS users") + "\n"
          )
          Users.ReadNewSet("nis")
          @local_users = Builtins.flatten(
            [@local_users, UsersCache.GetUsernames("nis")]
          )
        end

        Users.SetGUI(true) # reenables Report
        UI.CloseDialog
      end
      deep_copy(@local_users)
    end

### - (`Object`) initialize_mail_widgets(include_target)

    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
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    # File '../../src/include/mail/widgets.rb', line 18

    def initialize_mail_widgets(include_target)
      Yast.import "UI"

      textdomain "mail"

      Yast.import "Mail"
      Yast.import "MailAliases"

      Yast.import "Hostname"
      Yast.import "Address"

      Yast.import "Popup"
      Yast.import "Label"

      # ----------------------------------------------------------------

      # A list to check entered user names against.
      # It is initialized on first use.
      @local_users = nil

      # ----------------------------------------------------------------

      # A replacement for the Next button: "Finish", `next
      @finish_button = PushButton(
        Id(:next),
        Opt(:default, :key_F10),
        Label.FinishButton
      )
      #
      # **Structure:**
      #
      #     fetchmail
      #     	$[server:, protocol:, remote_user:, local_user:, password:, ...]
      @fetchmail_item = {}

      # don't forget to reset it!
      @fetchmail_item_touched = false

      # {#widget_def}
      @Widgets = {
        :foo                  => {
          "widget"   => TextEntry(),
          "opt"      => Opt(:notify),
          # optional
          "label"    => "",
          # if there are choices, they are used to construct the widget,
          # otherwise get is used
          "choices"  => [
            1,
            2,
            3
          ],
          # just a template, do not translate
          "help"     => _("."),
          "get"      => fun_ref(method(:Get_foo), "string ()"),
          "set"      => fun_ref(method(:Set_foo), "void (symbol)"),
          "validate" => fun_ref(method(:Validate_foo), "boolean (symbol)")
        },
        :outgoing_mail_server => {
          "widget"   => TextEntry(),
          # Translators: text entry label
          "label"    => _(
            "&Outgoing mail server"
          ),
          # help text
          "help"     => _(
            "\n" +
              "<p>The outgoing mail server is generally intended for dial-up connections.\n" +
              "Enter the Internet service provider's SMTP server, such as\n" +
              "<b>smtp.provider.com</b>.</p>\n"
          ),
          "get"      => fun_ref(method(:Get_outgoing_mail_server), "string ()"),
          "set"      => fun_ref(
            method(:Set_outgoing_mail_server),
            "void (symbol)"
          ),
          "validate" => fun_ref(
            method(:Validate_outgoing_mail_server),
            "boolean (symbol)"
          )
        },
        :from_header          => {
          "widget"   => TextEntry(),
          # Translators: text entry label
          "label"    => _(
            "Do&main for the 'From' header"
          ),
          # help text
          "help"     => _(
            "\n" +
              "<p>You may want the mail you sent to appear as if it originated from\n" +
              "<b>company.com</b> instead of <b>pc-042.company.com</b>.\n" +
              "Use the text box provided or a more detailed dialog.</p>\n"
          ),
          "get"      => fun_ref(method(:Get_from_header), "string ()"),
          "set"      => fun_ref(method(:Set_from_header), "void (symbol)"),
          "validate" => fun_ref(
            method(:Validate_from_header),
            "boolean (symbol)"
          )
        },
        :local_domains        => {
          "widget"   => TextEntry(),
          # Translators: text entry label
          "label"    => _(
            "&Domains for locally delivered mail"
          ),
          # help text
          "help"     => _(
            "\n" +
              "<p>Here, specify the domains for which the mail\n" +
              "will be delivered locally. If you enter nothing,\n" +
              "the local host name is assumed.</p>\n"
          ),
          "get"      => fun_ref(method(:Get_local_domains), "string ()"),
          "set"      => fun_ref(method(:Set_local_domains), "void (symbol)"),
          "validate" => fun_ref(
            method(:Validate_local_domains),
            "boolean (symbol)"
          )
        },
        :listen_remote        => {
          "widget" => CheckBox(),
          # check box label
          "label"  => _("Accept remote &SMTP connections"),
          # help text
          "help"   => _(
            "\n" +
              "<p>Mail can be received directly via the SMTP protocol\n" +
              "or it can be downloaded from\n" +
              "a POP or an IMAP server using <b>fetchmail</b>.</p>"
          ),
          "get"    => fun_ref(method(:Get_listen_remote), "boolean ()"),
          "set"    => fun_ref(method(:Set_listen_remote), "void (symbol)")
        },
        :use_amavis           => {
          "widget" => CheckBox(),
          # checkbox label
          "label"  => _("&Enable virus scanning (AMaViS)"),
          # we need notify option to enable disable dkim
          "opt"    => Opt(
            :notify
          ),
          # help text
          "help"   => _(
            "\n" +
              "<p><b>Enabling virus scanning (AMaViS)</b> checks incoming and outgoing mail\n" +
              "with AMaViS.</p>\n"
          ) +
            # help text
            _(
              "<p>Enabling AMaViS will also enable the following modules: </p>\n" +
                "<p><b>Spamassassin</b> SPAM scanner</p>\n" +
                "<p><b>DKIM</b> checks Domain Key signed incomming mails</p>\n" +
                "<p><b>Clamav</b> open source virus scanner engine</p>"
            ) +
            # help text
            _(
              "\n" +
                "<p>If AMaViS is not installed and you want to use it, it will be installed\n" +
                "automatically.</p>\n"
            ),
          "get"    => fun_ref(method(:Get_use_amavis), "boolean ()"),
          "set"    => fun_ref(method(:Set_use_amavis), "void (symbol)")
        },
        :use_dkim             => {
          "widget" => CheckBox(),
          # checkbox label
          "label"  => _(
            "&Enable DKIM signing for outgoing mails."
          ),
          # help text
          "help"   => _(
            "\n<p><b>Enabling DKIM signig for outgoing mails.</b></p>\n"
          ) +
            # help text
            _(
              "\n" +
                "<p>Enabling DKIM for outgoing emails requires additional actions. A SSL key\n" +
                "will be generated for the 'mydomain' value defined in Postfix. A new service\n" +
                "'submission' will be configured in Postfix. After this is set up you can send\n" +
                "email with this service 'submission' from 'mynetworks' with enabled SASL\n" +
                "authentication. Only the emails sent by this new service will be signed with\n" +
                "the domain key.</p>\n"
            ) +
            # help text
            _(
              "\n" +
                "<p>The public key of the domain key needs to be offered by a Domain Name\n" +
                "Service. The public key will be saved as a DNS TXT record\n" +
                "in <b>/var/db/dkim/[mydomain].public.txt</b> and needs to be deployed to an\n" +
                "according Domain Name Service. If there is a name service\n" +
                "running on this server, which is the authoritative server for that domain, the\n" +
                "public key will be added as a TXT record to that domain zone\n" +
                "automatically.</p>\n"
            ) +
            # help text
            _(
              "If you enable DKIM support, the virus scanning (AMaViS) will be enabled too."
            ),
          "get"    => fun_ref(method(:Get_use_dkim), "boolean ()"),
          "set"    => fun_ref(method(:Set_use_dkim), "void (symbol)")
        },
        :fm_server            => {
          "widget"   => TextEntry(),
          # Translators: text entry label
          "label"    => _("&Server"),
          "help"     => "",
          "get"      => fun_ref(method(:Get_fm_server), "string ()"),
          "set"      => fun_ref(method(:Set_fm_server), "void (symbol)"),
          "validate" => fun_ref(method(:Validate_fm_server), "boolean (symbol)")
        },
        :fm_protocol          => {
          "widget"  => ComboBox(),
          "opt"     => Opt(:hstretch),
          # Translators: combo box label
          "label"   => _("&Protocol"),
          "choices" => fun_ref(method(:Choices_protocol), "list ()"),
          "help"    => "",
          "get"     => fun_ref(method(:Get_fm_protocol), "string ()"),
          "set"     => fun_ref(method(:Set_fm_protocol), "void (symbol)")
        },
        :fm_remote_user       => {
          "widget"   => TextEntry(),
          # Translators: text entry label
          "label"    => _("&Remote user name"),
          "help"     => "",
          "get"      => fun_ref(method(:Get_fm_remote_user), "string ()"),
          "set"      => fun_ref(method(:Set_fm_remote_user), "void (symbol)"),
          "validate" => fun_ref(
            method(:Validate_fm_remote_user),
            "boolean (symbol)"
          )
        },
        :fm_password          => {
          "widget" => Password(),
          # Translators: text entry label
          "label"  => _("P&assword"),
          "help"   => "",
          "get"    => fun_ref(method(:Get_fm_password), "string ()"),
          "set"    => fun_ref(method(:Set_fm_password), "void (symbol)")
        },
        :fm_local_user        => {
          "widget"   => ComboBox(),
          # editable because entering a mail alias makes sense too
          # and we miss the nis users
          "opt"      => Opt(
            :hstretch,
            :editable
          ),
          # Translators: combo box label
          "label"    => _("&Local user"),
          "choices"  => fun_ref(method(:Choices_local_user), "list ()"),
          "help"     => "",
          "get"      => fun_ref(method(:Get_fm_local_user), "string ()"),
          "set"      => fun_ref(method(:Set_fm_local_user), "void (symbol)"),
          "validate" => fun_ref(
            method(:Validate_fm_local_user),
            "boolean (symbol)"
          )
        },
        :root_alias           => {
          "widget"   => TextEntry(),
          # Translators: text entry label
          "label"    => _(
            "&Forward root's mail to"
          ),
          # help text
          "help"     => _(
            "<p>It is recommended to have a regular user account\nfor the system administrator and redirect root's mail to this account.</p>"
          ),
          "get"      => fun_ref(method(:Get_root_alias), "string ()"),
          "set"      => fun_ref(method(:Set_root_alias), "void (symbol)"),
          "validate" => fun_ref(
            method(:Validate_root_alias),
            "boolean (symbol)"
          )
        },
        :delivery_mode        => {
          "widget"   => ComboBox(),
          "opt"      => Opt(:hstretch),
          # Translators: combo box label
          # /etc/sysconfig/postfix: POSTFIX_MDA
          "label"    => _(
            "&Delivery Mode"
          ),
          "choices"  => fun_ref(method(:Choices_delivery_mode), "list ()"),
          # help text
          "help"     => _(
            "<p>The <b>delivery mode</b> is usually <b>Directly</b>, unless you do not forward root's mail or want to access the mail via IMAP.</p>"
          ),
          "get"      => fun_ref(method(:Get_delivery_mode), "symbol ()"),
          "set"      => fun_ref(method(:Set_delivery_mode), "void (symbol)"),
          "validate" => fun_ref(
            method(:Validate_delivery_mode),
            "boolean (symbol)"
          )
        }
      }
    end

### - (`Object`) listToString(alist)

Formats a list for a TextEntry, separating the elements by “, ”

Parameters:

- alist (`Array<String>`) —

  a list

Returns:

- a string

    418
    419
    420
    421
    # File '../../src/include/mail/widgets.rb', line 418

    def listToString(alist)
      alist = deep_copy(alist)
      Builtins.mergestring(alist, ", ")
    end

### - (`Object`) Set_delivery_mode(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    # File '../../src/include/mail/widgets.rb', line 798

    def Set_delivery_mode(id)
      val = Convert.to_symbol(UI.QueryWidget(Id(id), :Value))
      ui2scr = {
        :dm_local    => :local,
        :dm_procmail => :procmail,
        :dm_cyrus    => :cyrus
      }
      val = Ops.get_symbol(ui2scr, val, :local)
      Mail.Touch(Mail.postfix_mda != val)
      Mail.postfix_mda = val

      nil
    end

### - (`Object`) Set_fm_local_user(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    731
    732
    733
    734
    735
    736
    737
    738
    # File '../../src/include/mail/widgets.rb', line 731

    def Set_fm_local_user(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      @fetchmail_item_touched = @fetchmail_item_touched ||
        Ops.get_string(@fetchmail_item, "local_user", "") != val
      @fetchmail_item = Builtins.add(@fetchmail_item, "local_user", val)

      nil
    end

### - (`Object`) Set_fm_password(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    714
    715
    716
    717
    718
    719
    720
    721
    # File '../../src/include/mail/widgets.rb', line 714

    def Set_fm_password(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      @fetchmail_item_touched = @fetchmail_item_touched ||
        Ops.get_string(@fetchmail_item, "password", "") != val
      @fetchmail_item = Builtins.add(@fetchmail_item, "password", val)

      nil
    end

### - (`Object`) Set_fm_protocol(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    667
    668
    669
    670
    671
    672
    673
    674
    # File '../../src/include/mail/widgets.rb', line 667

    def Set_fm_protocol(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      @fetchmail_item_touched = @fetchmail_item_touched ||
        Ops.get_string(@fetchmail_item, "protocol", "") != val
      @fetchmail_item = Builtins.add(@fetchmail_item, "protocol", val)

      nil
    end

### - (`Object`) Set_fm_remote_user(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    683
    684
    685
    686
    687
    688
    689
    690
    # File '../../src/include/mail/widgets.rb', line 683

    def Set_fm_remote_user(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      @fetchmail_item_touched = @fetchmail_item_touched ||
        Ops.get_string(@fetchmail_item, "remote_user", "") != val
      @fetchmail_item = Builtins.add(@fetchmail_item, "remote_user", val)

      nil
    end

### - (`Object`) Set_fm_server(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    635
    636
    637
    638
    639
    640
    641
    642
    # File '../../src/include/mail/widgets.rb', line 635

    def Set_fm_server(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      @fetchmail_item_touched = @fetchmail_item_touched ||
        Ops.get_string(@fetchmail_item, "server", "") != val
      @fetchmail_item = Builtins.add(@fetchmail_item, "server", val)

      nil
    end

### - (`Object`) Set_foo(id)

(sample) Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    443
    444
    445
    446
    447
    448
    449
    450
    # File '../../src/include/mail/widgets.rb', line 443

    def Set_foo(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      @fetchmail_item_touched = @fetchmail_item_touched ||
        Ops.get_string(@fetchmail_item, "protocol", "") != val
      @fetchmail_item = Builtins.add(@fetchmail_item, "protocol", val)

      nil
    end

### - (`Object`) Set_from_header(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    522
    523
    524
    525
    526
    527
    528
    # File '../../src/include/mail/widgets.rb', line 522

    def Set_from_header(id)
      fh = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      Mail.Touch(Mail.from_header != fh)
      Mail.from_header = fh

      nil
    end

### - (`Object`) Set_listen_remote(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    589
    590
    591
    592
    593
    594
    595
    # File '../../src/include/mail/widgets.rb', line 589

    def Set_listen_remote(id)
      lr = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
      Mail.Touch(Mail.listen_remote != lr)
      Mail.listen_remote = lr

      nil
    end

### - (`Object`) Set_local_domains(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    547
    548
    549
    550
    551
    552
    553
    # File '../../src/include/mail/widgets.rb', line 547

    def Set_local_domains(id)
      lld = stringToList(Convert.to_string(UI.QueryWidget(Id(id), :Value)))
      Mail.Touch(Mail.local_domains != lld)
      Mail.local_domains = deep_copy(lld)

      nil
    end

### - (`Object`) Set_outgoing_mail_server(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    475
    476
    477
    478
    479
    480
    481
    # File '../../src/include/mail/widgets.rb', line 475

    def Set_outgoing_mail_server(id)
      oms = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      Mail.Touch(Mail.outgoing_mail_server != oms)
      Mail.outgoing_mail_server = oms

      nil
    end

### - (`Object`) Set_root_alias(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    762
    763
    764
    765
    766
    767
    768
    # File '../../src/include/mail/widgets.rb', line 762

    def Set_root_alias(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      Mail.Touch(MailAliases.root_alias != val)
      MailAliases.root_alias = val

      nil
    end

### - (`Object`) Set_use_amavis(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    604
    605
    606
    607
    608
    609
    610
    # File '../../src/include/mail/widgets.rb', line 604

    def Set_use_amavis(id)
      am = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
      Mail.Touch(Mail.use_amavis != am)
      Mail.use_amavis = am

      nil
    end

### - (`Object`) Set_use_dkim(id)

Set a variable acording to widget value

Parameters:

- id (`Symbol`) —

  widget id

    619
    620
    621
    622
    623
    624
    625
    # File '../../src/include/mail/widgets.rb', line 619

    def Set_use_dkim(id)
      dkim = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))
      Mail.Touch(Mail.use_dkim != dkim)
      Mail.use_dkim = dkim

      nil
    end

### - (`Object`) stringToList(astring)

Splits a TextEntry string into a list of strings separated by spaces, commas or semicolons. Empty strings are removed.

Parameters:

- astring (`String`) —

  a string

Returns:

- a list of strings

    428
    429
    430
    431
    # File '../../src/include/mail/widgets.rb', line 428

    def stringToList(astring)
      alist = Builtins.splitstring(astring, " ,;")
      Builtins.filter(alist) { |s| s != "" }
    end

### - (`Object`) Validate_delivery_mode(id)

Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    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
    # File '../../src/include/mail/widgets.rb', line 815

    def Validate_delivery_mode(id)
      val = Convert.to_symbol(UI.QueryWidget(Id(id), :Value))
      # Procmail is only OK if root has an alias
      # Because postfix runs procmail as nobody instead of root
      # and the mail would end up in the wrong place
      ok = true

      # the root alias widget should be in the same dialog!
      ra_id = :root_alias
      if !UI.WidgetExists(Id(ra_id))
        Builtins.y2error(
          "Widget %1 not found, skipping validation of %2",
          ra_id,
          id
        )
      else
        ra_val = Convert.to_string(UI.QueryWidget(Id(ra_id), :Value))
        ok = false if ra_val == "" && val == :dm_procmail
      end

      if !ok
        UI.SetFocus(Id(id))
        # Translators: error popup
        # Validation
        Popup.Error(_("Cannot use procmail when root's mail is not forwarded."))
        return false
      end
      true
    end

### - (`Object`) Validate_fm_local_user(id)

Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    # File '../../src/include/mail/widgets.rb', line 743

    def Validate_fm_local_user(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      if !check_mail_local_part(val)
        # it may be ok if it is directed to an alias
        UI.SetFocus(Id(id))
        # Translators: error popup
        Popup.Error(_("The user name format is incorrect."))
        return false
      end
      true
    end

### - (`Object`) Validate_fm_remote_user(id)

also used for smtp_auth user Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    # File '../../src/include/mail/widgets.rb', line 696

    def Validate_fm_remote_user(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      if val == ""
        UI.SetFocus(Id(id))
        # Translators: error popup
        Popup.Error(_("The user name format is incorrect."))
        return false
      end
      true
    end

### - (`Object`) Validate_fm_server(id)

also used for smtp_auth server Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    # File '../../src/include/mail/widgets.rb', line 648

    def Validate_fm_server(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      if !Hostname.CheckDomain(val)
        UI.SetFocus(Id(id))
        # Translators: error popup
        msg = _("The host name is incorrect")
        Popup.Error(msg)
        return false
      end
      true
    end

### - (`Object`) Validate_foo(id)

(sample) Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    # File '../../src/include/mail/widgets.rb', line 456

    def Validate_foo(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      if !Hostname.CheckDomain(val)
        UI.SetFocus(Id(id))
        # Translators: error popup
        msg = _("The host name is incorrect")
        Popup.Error(msg)
        return false
      end
      true
    end

### - (`Object`) Validate_from_header(id)

    530
    531
    532
    533
    534
    535
    536
    537
    538
    # File '../../src/include/mail/widgets.rb', line 530

    def Validate_from_header(id)
      fh = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      if fh != "" && !Hostname.CheckDomain(fh)
        UI.SetFocus(Id(id))
        Popup.Error(Hostname.ValidDomain)
        return false
      end
      true
    end

### - (`Object`) Validate_local_domains(id)

Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    # File '../../src/include/mail/widgets.rb', line 558

    def Validate_local_domains(id)
      lld = stringToList(Convert.to_string(UI.QueryWidget(Id(id), :Value)))
      # find one that fails
      if Builtins.find(lld) do |s|
          # #36871
          # Strip \$ which marks postfix substitutions:
          # Verify that they only occur together
          # and then remove them individually. Elementary, dear Watson.
          if Builtins.regexpmatch(s, "\\\\[^$]") ||
              Builtins.regexpmatch(s, "\\\\$") ||
              Builtins.regexpmatch(s, "[^\\]\\$") ||
              Builtins.regexpmatch(s, "^\\$")
            next true
          end
          s = Builtins.deletechars(s, "\\$")
          !Hostname.CheckDomain(s)
        end != nil
        UI.SetFocus(Id(id))
        Popup.Error(Hostname.ValidDomain)
        return false
      end
      true
    end

### - (`Object`) Validate_outgoing_mail_server(id)

Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    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
    # File '../../src/include/mail/widgets.rb', line 486

    def Validate_outgoing_mail_server(id)
      # when validating: may be enclosed in brackets (prevents mx lookups)
      oms = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      # watch this: "[", no brackets, "]"
      oms_no_brackets = Builtins.regexpmatch(oms, "[[][^][]*[]]:.*") ?
        Builtins.regexpsub(oms, ".(.*).:.*", "\\1") :
        oms

      if oms_no_brackets == oms
        oms_no_brackets = Builtins.regexpmatch(oms, "[[][^][]*[]]") ?
          Builtins.regexpsub(oms, ".(.*).", "\\1") :
          oms
      end
      if oms_no_brackets == oms
        oms_no_brackets = Builtins.regexpmatch(oms, ".*:.*") ?
          Builtins.regexpsub(oms, "(.*):.*", "\\1") :
          oms
      end

      if oms_no_brackets != "" && !Address.Check(oms_no_brackets) ||
          oms_no_brackets == "" && Mail.connection_type == :dialup
        UI.SetFocus(Id(id))
        Popup.Error(Address.Valid4)
        return false
      end
      true
    end

### - (`Object`) Validate_root_alias(id)

Validate widget value

Parameters:

- id (`Symbol`) —

  widget id

Returns:

- valid?

    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    # File '../../src/include/mail/widgets.rb', line 773

    def Validate_root_alias(id)
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
      # user@machine, \\root - too much variation, don't check yet
      if false
        UI.SetFocus(Id(id))
        # Translators: error popup
        Popup.Error(_("The user name format is incorrect."))
        return false
      end
      true
    end