Module: Yast::DnsServerOptionsInclude

Defined in:
../../src/include/dns-server/options.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) ASummary(opt_id, key)

A popup



175
176
177
178
179
180
181
# File '../../src/include/dns-server/options.rb', line 175

def ASummary(opt_id, key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  addr = Ops.get_string(@current_zone, ["records", index, "value"], "A")
  # table entry, %1 is IP address
  Builtins.sformat(_("Host %1"), addr)
end

- (Object) CNAMESummary(opt_id, key)

CNAME popup



213
214
215
216
217
218
219
# File '../../src/include/dns-server/options.rb', line 213

def CNAMESummary(opt_id, key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  addr = Ops.get_string(@current_zone, ["records", index, "value"], "A")
  # table entry, %1 is host name
  Builtins.sformat(_("Alias for %1"), addr)
end

- (Object) getAPopup



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
# File '../../src/include/dns-server/options.rb', line 183

def getAPopup
  {
    "table" => {
      "summary" => fun_ref(method(:ASummary), "string (any, string)"),
      # combo box item, A is more technical description
      "label"   => _(
        "A -- Domain Name Translation"
      )
    },
    "popup" => {
      "widget"        => :custom,
      "custom_widget" => HBox(
        HSpacing(1),
        VBox(
          HSpacing(50),
          InputField(Id(:key), Opt(:hstretch), Label.HostName),
          VSpacing(2),
          # text entry
          InputField(Id(:value), Opt(:hstretch), _("&IP Addresses")),
          VSpacing(1)
        ),
        HSpacing(1)
      )
    }
  }
end

- (Object) getCNAMEPopup



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
# File '../../src/include/dns-server/options.rb', line 221

def getCNAMEPopup
  {
    "table" => {
      "summary" => fun_ref(method(:CNAMESummary), "string (any, string)"),
      # combo box item, CNAME is more technical description
      "label"   => _(
        "CNAME -- Alias for Domain Name"
      )
    },
    "popup" => {
      "widget"        => :custom,
      "custom_widget" => HBox(
        HSpacing(1),
        VBox(
          HSpacing(30),
          # text entry
          InputField(Id(:key), Opt(:hstretch), _("&Alias")),
          VSpacing(1),
          # text entry
          InputField(Id(:value), Opt(:hstretch), _("&Base Host Name")),
          VSpacing(1)
        ),
        HSpacing(1)
      )
    }
  }
end

- (Object) getMXPopup



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File '../../src/include/dns-server/options.rb', line 411

def getMXPopup
  {
    "table" => {
      "summary" => fun_ref(method(:MXSummary), "string (any, string)"),
      # combo box item, MX is more technical description
      "label"   => _(
        "MX -- Mail Relay"
      )
    },
    "popup" => {
      "init"          => fun_ref(method(:MXInit), "void (any, string)"),
      "store"         => fun_ref(method(:MXStore), "void (any, string)"),
      "widget"        => :custom,
      "custom_widget" => HBox(
        HSpacing(1),
        VBox(
          HSpacing(30),
          # text entry
          InputField(Id(:key), Opt(:hstretch), _("&Domain Name")),
          VSpacing(1),
          # text entry
          InputField(Id(:value), Opt(:hstretch), _("&Mail Relay")),
          VSpacing(1),
          # int field
          IntField(Id(:prio), _("&Priority"), 0, 100, 0),
          VSpacing(1)
        ),
        HSpacing(1)
      )
    }
  }
end

- (Object) getNSPopup



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File '../../src/include/dns-server/options.rb', line 298

def getNSPopup
  {
    "table" => {
      "summary" => fun_ref(method(:NSSummary), "string (any, string)"),
      # combo box item, NS is more technical description
      "label"   => _(
        "NS -- Name Server"
      )
    },
    "popup" => {
      "widget"        => :custom,
      "custom_widget" => HBox(
        HSpacing(1),
        VBox(
          HSpacing(30),
          # text entry
          InputField(Id(:key), Opt(:hstretch), _("&Domain")),
          VSpacing(1),
          # text entry
          InputField(Id(:value), Opt(:hstretch), _("&Name Server")),
          VSpacing(1)
        ),
        HSpacing(1)
      )
    }
  }
end

- (Object) getPTRPopup



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
# File '../../src/include/dns-server/options.rb', line 260

def getPTRPopup
  {
    "table" => {
      "summary" => fun_ref(method(:PTRSummary), "string (any, string)"),
      # combo box item, PTR is more technical description
      "label"   => _(
        "PTR -- Reverse Translation"
      )
    },
    "popup" => {
      "widget"        => :custom,
      "custom_widget" => HBox(
        HSpacing(1),
        VBox(
          HSpacing(30),
          # text entry
          InputField(Id(:key), Opt(:hstretch), _("&IP Address")),
          VSpacing(1),
          # text entry
          InputField(Id(:value), Opt(:hstretch), Label.HostName),
          VSpacing(1)
        ),
        HSpacing(1)
      )
    }
  }
end

- (Object) globalPopupInit(opt_id, opt_key)

Fallback initialization function of a table entry / popup

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File '../../src/include/dns-server/options.rb', line 27

def globalPopupInit(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  if opt_id != nil
    oid = Convert.to_integer(opt_id)
    UI.ChangeWidget(
      Id(opt_key),
      :Value,
      Ops.get_string(@current_section, [oid, "value"], "")
    )
  end
  UI.SetFocus(Id(opt_key))

  nil
end

- (Object) globalPopupStore(opt_id, opt_key)

Fallback store function of a table entry / popup

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File '../../src/include/dns-server/options.rb', line 45

def globalPopupStore(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  if opt_id == nil
    new_opt = {
      "key"   => opt_key,
      "value" => UI.QueryWidget(Id(opt_key), :Value)
    }
    @current_section = Builtins.add(@current_section, new_opt)
  else
    oid = Convert.to_integer(opt_id)
    Ops.set(
      @current_section,
      [oid, "value"],
      UI.QueryWidget(Id(opt_key), :Value)
    )
  end
  DnsServer.SetModified

  nil
end

- (String) globalTableEntrySummary(opt_id, opt_key)

Fallback summary function of a table entry / popup

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key

Returns:

  • (String)

    table entry summary



70
71
72
73
74
75
76
77
# File '../../src/include/dns-server/options.rb', line 70

def globalTableEntrySummary(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  oid = Convert.to_integer(opt_id)
  Builtins.sformat(
    "%1",
    Ops.get_string(@current_section, [oid, "value"], "")
  )
end

- (Object) initialize_dns_server_options(include_target)



14
15
16
17
18
19
20
# File '../../src/include/dns-server/options.rb', line 14

def initialize_dns_server_options(include_target)
  textdomain "dns-server"

  Yast.import "Label"
  Yast.import "CWM"
  Yast.import "DnsServer"
end

- (Hash) InitPopups

Initialize all poups

Returns:

  • (Hash)

    description of all popups/options



446
447
448
449
450
451
452
453
454
# File '../../src/include/dns-server/options.rb', line 446

def InitPopups
  {
    "A"     => getAPopup,
    "CNAME" => getCNAMEPopup,
    "PTR"   => getPTRPopup,
    "NS"    => getNSPopup,
    "MX"    => getMXPopup
  }
end

- (Object) masterPopupInit(opt_id, opt_key)

Fallback initialization function of a table entry / popup

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File '../../src/include/dns-server/options.rb', line 85

def masterPopupInit(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  key = ""
  value = ""
  if index != nil
    key = Ops.get_string(@current_zone, ["records", index, "key"], "")
    value = Ops.get_string(@current_zone, ["records", index, "value"], "")
  end
  UI.ChangeWidget(:key, :Value, key)
  UI.ChangeWidget(:value, :Value, value)
  UI.SetFocus(:key)

  nil
end

- (Object) masterPopupStore(opt_id, opt_key)

Fallback store function of a table entry / popup

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key



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
# File '../../src/include/dns-server/options.rb', line 104

def masterPopupStore(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  key = Convert.to_string(UI.QueryWidget(:key, :Value))
  value = Convert.to_string(UI.QueryWidget(:value, :Value))
  if index != nil
    @current_zone_upd_ops = Builtins.add(
      @current_zone_upd_ops,
      {
        "operation" => "delete",
        "type"      => opt_key,
        "key"       => Ops.get_string(
          @current_zone,
          ["records", index, "key"],
          ""
        ),
        "value"     => Ops.get_string(
          @current_zone,
          ["records", index, "value"],
          ""
        )
      }
    )
    Ops.set(@current_zone, ["records", index, "value"], value)
    Ops.set(@current_zone, ["records", index, "key"], key)
  else
    new_rec = { "key" => key, "value" => value, "type" => opt_key }
    Ops.set(
      @current_zone,
      "records",
      Builtins.add(Ops.get_list(@current_zone, "records", []), new_rec)
    )
  end
  @current_zone_upd_ops = Builtins.add(
    @current_zone_upd_ops,
    {
      "operation" => "add",
      "type"      => opt_key,
      "key"       => key,
      "value"     => value
    }
  )

  nil
end

- (String) masterTableEntrySummary(opt_id, opt_key)

Fallback summary function of a table entry / popup

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key

Returns:

  • (String)

    table entry summary



154
155
156
157
158
159
160
# File '../../src/include/dns-server/options.rb', line 154

def masterTableEntrySummary(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  addr = Ops.get_string(@current_zone, ["records", index, "value"], "A")
  # %1 is usually an IP address
  Builtins.sformat(_("Unknown Record Type: %1"), addr)
end

- (String) masterTableLabelFunc(opt_id, opt_key)

Fallback function for determining the first column of the table in order not to depend on the option key

Parameters:

  • opt_id (Object)

    any option id

  • opt_key (String)

    any option key

Returns:

  • (String)

    the table entry



167
168
169
170
171
# File '../../src/include/dns-server/options.rb', line 167

def masterTableLabelFunc(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  Ops.get_string(@current_zone, ["records", index, "key"], "")
end

- (Object) MXInit(opt_id, key)



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File '../../src/include/dns-server/options.rb', line 340

def MXInit(opt_id, key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  key = ""
  value = ""
  if index != nil
    key = Ops.get_string(@current_zone, ["records", index, "key"], "")
    value = Ops.get_string(@current_zone, ["records", index, "value"], "")
  end
  l = Builtins.splitstring(value, " ")
  l = Builtins.filter(l) { |s| s != "" }
  prio = Ops.get(l, 0, "")
  Ops.set(l, 0, "")
  l = Builtins.filter(l) { |s| s != "" }
  value = Builtins.mergestring(l, " ")
  UI.ChangeWidget(:key, :Value, key)
  UI.ChangeWidget(:value, :Value, value)
  UI.ChangeWidget(:prio, :Value, Builtins.tointeger(prio))
  UI.SetFocus(:key)

  nil
end

- (Object) MXStore(opt_id, opt_key)



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
# File '../../src/include/dns-server/options.rb', line 363

def MXStore(opt_id, opt_key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  key = Convert.to_string(UI.QueryWidget(:key, :Value))
  value = Convert.to_string(UI.QueryWidget(:value, :Value))
  prio = Convert.to_integer(UI.QueryWidget(:prio, :Value))
  value = Builtins.sformat("%1 %2", prio, value)
  if index != nil
    @current_zone_upd_ops = Builtins.add(
      @current_zone_upd_ops,
      {
        "operation" => "delete",
        "type"      => opt_key,
        "key"       => Ops.get_string(
          @current_zone,
          ["records", index, "key"],
          ""
        ),
        "value"     => Ops.get_string(
          @current_zone,
          ["records", index, "value"],
          ""
        )
      }
    )
    Ops.set(@current_zone, ["records", index, "value"], value)
    Ops.set(@current_zone, ["records", index, "key"], key)
  else
    new_rec = { "key" => key, "value" => value, "type" => opt_key }
    Ops.set(
      @current_zone,
      "records",
      Builtins.add(Ops.get_list(@current_zone, "records", []), new_rec)
    )
  end
  @current_zone_upd_ops = Builtins.add(
    @current_zone_upd_ops,
    {
      "operation" => "add",
      "type"      => opt_key,
      "key"       => key,
      "value"     => value
    }
  )

  nil
end

- (Object) MXSummary(opt_id, key)



326
327
328
329
330
331
332
333
334
335
336
337
338
# File '../../src/include/dns-server/options.rb', line 326

def MXSummary(opt_id, key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  addr = Ops.get_string(@current_zone, ["records", index, "value"], "A")
  l = Builtins.splitstring(addr, " ")
  l = Builtins.filter(l) { |s| s != "" }
  prio = Ops.get(l, 0, "")
  Ops.set(l, 0, "")
  l = Builtins.filter(l) { |s| s != "" }
  addr = Builtins.mergestring(l, " ")
  # table entry, %1 is host name, %2 is integer
  Builtins.sformat(_("Mail Relay %1, Priority %2"), addr, prio)
end

- (Object) NSSummary(opt_id, key)



290
291
292
293
294
295
296
# File '../../src/include/dns-server/options.rb', line 290

def NSSummary(opt_id, key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  addr = Ops.get_string(@current_zone, ["records", index, "value"], "A")
  # table entry, %1 is host name
  Builtins.sformat(_("Name Server %1"), addr)
end

- (Object) PTRSummary(opt_id, key)

PTR popup



252
253
254
255
256
257
258
# File '../../src/include/dns-server/options.rb', line 252

def PTRSummary(opt_id, key)
  opt_id = deep_copy(opt_id)
  index = Convert.to_integer(opt_id)
  addr = Ops.get_string(@current_zone, ["records", index, "value"], "A")
  # table entry, %1 is host name
  Builtins.sformat(_("Pointer to %1"), addr)
end