Module: Yast::SquidPopupDialogsInclude

Defined in:
../../src/include/squid/popup_dialogs.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) AddEditACLDialog(id_item)



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
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
# File '../../src/include/squid/popup_dialogs.rb', line 317

def AddEditACLDialog(id_item)
  ret = false
  ui = nil
  orig_type = ""
  type = ""
  label = id_item == nil ? _("Add New ACL Group") : _("Edit ACL Group")
  contents = HBox(
    HWeight(30, RichText(Id("help_text"), "")),
    HWeight(
      70,
      VBox(
        Label(label),
        VSpacing(0.5),
        TextEntry(Id("name"), _("Name"), ""),
        Left(
          ComboBox(
            Id("type"),
            Opt(:notify),
            _("Type"),
            SquidACL.GetTypesToComboBox
          )
        ),
        ReplacePoint(Id(:replace_point), Empty()),
        VStretch(),
        ButtonBox(
          PushButton(Id(:ok), Label.OKButton),
          PushButton(Id(:cancel), Label.CancelButton)
        )
      )
    )
  )

  UI.OpenDialog(contents)

  InitAddEditACLDialog(id_item)

  orig_type = Convert.to_string(UI.QueryWidget(Id("type"), :Value))
  SquidACL.Replace(:replace_point, orig_type)
  SquidACL.InitWidget(orig_type, id_item, "help_text")

  while true
    ui = UI.UserInput

    if ui == :cancel || ui == :abort
      ret = false
      break
    elsif ui == :ok
      if StoreDataFromAddEditACLDialog(id_item)
        ret = true
        break
      end
    elsif ui == "type"
      type = Convert.to_string(UI.QueryWidget(Id("type"), :Value))
      SquidACL.Replace(:replace_point, type)
      if type == orig_type
        SquidACL.InitWidget(type, id_item, "help_text")
      else
        SquidACL.InitWidget(type, nil, "help_text")
      end
    end
  end


  UI.CloseDialog

  ret
end

- (Object) AddEditHttpAccessDialog(id_item)



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
# File '../../src/include/squid/popup_dialogs.rb', line 218

def AddEditHttpAccessDialog(id_item)
  ret = false
  ui = nil
  acl = ""
  _not = false
  tmp = nil
  tmp_term = nil
  id_acl = 0
  label = id_item == nil ? _("Add New HTTP Access") : _("Edit HTTP Access")
  contents = VBox(
    Label(label),
    VSpacing(0.5),
    ComboBox(
      Id("allow_deny"),
      _("Allow/Deny"),
      [Item(Id("allow"), _("Allow")), Item(Id("deny"), _("Deny"))]
    ),
    #`VSpacing(),
    MinSize(
      25,
      7,
      Table(Id("acls"), Opt(:notify), Header("   ", _("ACL")), [])
    ),
    Left(
      HBox(
        PushButton(Id(:del), Label.DeleteButton),
        PushButton(Id(:opposite), _("O&pposite"))
      )
    ),
    VSpacing(0.5),
    MinWidth(
      25,
      Frame(
        _("Add ACL"),
        VSquash(
          HBox(
            Bottom(CheckBox(Id("acl_not"), _("not"))),
            MinWidth(15, ComboBox(Id("acl"), "ACL", [])),
            Bottom(PushButton(Id(:add), Label.AddButton))
          )
        )
      )
    ),
    VStretch(),
    ButtonBox(
      PushButton(Id(:ok), Label.OKButton),
      PushButton(Id(:cancel), Label.CancelButton)
    )
  )

  UI.OpenDialog(contents)

  InitAddEditHttpAccessDialog(id_item)

  while true
    ui = UI.UserInput

    if ui == :cancel || ui == :abort
      ret = false
      break
    elsif ui == :ok
      if StoreDataFromAddEditHttpAccessDialog(id_item)
        ret = true
        break
      end
    elsif ui == :add
      acl = Convert.to_string(UI.QueryWidget(Id("acl"), :Value))
      _not = Convert.to_boolean(UI.QueryWidget(Id("acl_not"), :Value))
      if Ops.greater_than(Builtins.size(acl), 0)
        addItemToAddEditHttpAccessDialog(_not, acl)
        InitAddEditHttpAccessDialog(nil)
      end
    elsif ui == :del
      id_acl = delItemFromAddEditHttpAccessDialog(
        Convert.to_integer(UI.QueryWidget(Id("acls"), :CurrentItem))
      )
      InitAddEditHttpAccessDialog(nil)
      UI.ChangeWidget(Id("acls"), :CurrentItem, id_acl)
    elsif ui == :opposite || ui == "acls"
      id_acl = Convert.to_integer(UI.QueryWidget(Id("acls"), :CurrentItem))
      tmp_term = Convert.to_term(
        UI.QueryWidget(Id("acls"), term(:Item, id_acl))
      )

      if Ops.get_string(tmp_term, 1, "") == "not"
        UI.ChangeWidget(Id("acls"), term(:Item, id_acl, 0), "")
      else
        UI.ChangeWidget(Id("acls"), term(:Item, id_acl, 0), "not")
      end
    end
  end


  UI.CloseDialog

  ret
end

- (Object) AddEditHttpPortDialog(id_item)

**************** HTTP PORT ******************* returns true if something added/edited otherwise false



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
# File '../../src/include/squid/popup_dialogs.rb', line 44

def AddEditHttpPortDialog(id_item)
  ui = nil
  ret = false
  label = id_item == nil ?
    _("Add New HTTP Port") :
    _("Edit Current HTTP Port")
  contents = VBox(
    Label(label),
    VSpacing(0.5),
    TextEntry(Id("host"), _("Host"), ""),
    TextEntry(Id("port"), _("Port"), ""),
    Left(CheckBox(Id("transparent"), _("Transparent"), false)),
    VSpacing(),
    VStretch(),
    ButtonBox(
      PushButton(Id(:ok), Label.OKButton),
      PushButton(Id(:cancel), Label.CancelButton)
    )
  )

  UI.OpenDialog(Opt(:decorated), contents)
  UI.ChangeWidget(Id("port"), :ValidChars, "1234567890")
  UI.ChangeWidget(Id("host"), :InputMaxLength, 22)

  InitAddEditHttpPortDialog(id_item)

  while true
    ui = UI.UserInput

    if ui == :abort || ui == :cancel
      ret = false
      break
    elsif ui == :ok
      if StoreDataFromAddEditHttpPortDialog(id_item)
        ret = true
        break
      end
    end
  end

  UI.CloseDialog
  ret
end

- (Object) AddEditRefreshPatternDialog(id_item)

**************** CACHE ***********************



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
# File '../../src/include/squid/popup_dialogs.rb', line 91

def AddEditRefreshPatternDialog(id_item)
  ret = false
  ui = nil
  label = id_item == nil ?
    _("Add New Refresh Pattern") :
    _("Edit Current refresh Pattern")
  tmp = nil

  contents = VBox(
    Label(label),
    VSpacing(0.5),
    VSquash(
      HBox(
        TextEntry(Id("regexp"), _("Regular Expression"), ""),
        Bottom(
          CheckBox(Id("regexp_case_insensitive"), _("Case Insensitive"))
        )
      )
    ),
    IntField(Id("min"), Opt(:notify), _("Min (in minutes)"), 0, 99999, 0),
    IntField(Id("percent"), _("Percent"), 0, 99999, 0),
    IntField(Id("max"), Opt(:notify), _("Max (in minutes)"), 0, 99999, 0),
    VSpacing(),
    VStretch(),
    ButtonBox(
      PushButton(Id(:ok), Label.OKButton),
      PushButton(Id(:cancel), Label.CancelButton)
    )
  )

  UI.OpenDialog(Opt(:decorated), contents)

  InitAddEditRefreshPatternDialog(id_item)

  while true
    ui = UI.UserInput

    if ui == :cancel || ui == :abort
      ret = false
      break
    elsif ui == :ok
      if StoreDataFromAddEditRefreshPatternDialog(id_item)
        ret = true
        break
      end
    elsif ui == "min"
      if Ops.greater_than(
          Convert.to_integer(tmp),
          Convert.to_integer(UI.QueryWidget(Id("max"), :Value))
        )
        UI.ChangeWidget(Id("max"), :Value, tmp)
      end
    elsif ui == "max"
      tmp = UI.QueryWidget(Id("max"), :Value)
      if Ops.greater_than(
          Convert.to_integer(UI.QueryWidget(Id("min"), :Value)),
          Convert.to_integer(tmp)
        )
        UI.ChangeWidget(Id("min"), :Value, tmp)
      end
    end
  end

  UI.CloseDialog
  ret
end

- (Object) addItemToAddEditHttpAccessDialog(_not, item)

**************** ACCESS CONTROL **************



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
# File '../../src/include/squid/popup_dialogs.rb', line 161

def addItemToAddEditHttpAccessDialog(_not, item)
  items = []

  i = 0
  Builtins.foreach(
    Convert.convert(
      UI.QueryWidget(Id("acls"), :Items),
      :from => "any",
      :to   => "list <term>"
    )
  ) do |value|
    items = Builtins.add(
      items,
      Item(
        Id(i),
        Ops.get_string(value, 1, ""),
        Ops.get_string(value, 2, "")
      )
    )
    i = Ops.add(i, 1)
  end
  items = Builtins.add(items, Item(Id(i), _not == true ? "not" : "", item))
  UI.ChangeWidget(Id("acls"), :Items, items)

  nil
end

- (Object) delItemFromAddEditHttpAccessDialog(id_item)



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
# File '../../src/include/squid/popup_dialogs.rb', line 187

def delItemFromAddEditHttpAccessDialog(id_item)
  items = []

  i = 0
  Builtins.foreach(
    Convert.convert(
      UI.QueryWidget(Id("acls"), :Items),
      :from => "any",
      :to   => "list <term>"
    )
  ) do |value|
    if Ops.get(value, 0) != Id(id_item)
      items = Builtins.add(
        items,
        Item(
          Id(i),
          Ops.get_string(value, 1, ""),
          Ops.get_string(value, 2, "")
        )
      )
      i = Ops.add(i, 1)
    end
  end
  UI.ChangeWidget(Id("acls"), :Items, items)
  if Ops.greater_or_equal(id_item, Builtins.size(items))
    id_item = Ops.subtract(id_item, 1)
  end
  id_item
end

- (Object) initialize_squid_popup_dialogs(include_target)



30
31
32
33
34
35
36
37
38
39
40
# File '../../src/include/squid/popup_dialogs.rb', line 30

def initialize_squid_popup_dialogs(include_target)
  Yast.import "UI"

  textdomain "squid"
  Yast.import "Label"
  Yast.import "SquidACL"

  Yast.include include_target, "squid/inits.rb"
  Yast.include include_target, "squid/store_del.rb"
  Yast.include include_target, "squid/helper_functions.rb"
end