Module: Yast::PartitioningEpLoopDialogsInclude

Defined in:
../../src/include/partitioning/ep-loop-dialogs.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) DlgCreateLoop(data)



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
# File '../../src/include/partitioning/ep-loop-dialogs.rb', line 240

def DlgCreateLoop(data)
  aliases = {
    "NameSize"    => lambda do
      (
        data_ref = arg_ref(data.value);
        _MiniWorkflowStepLoopNameSize_result = MiniWorkflowStepLoopNameSize(
          data_ref
        );
        data.value = data_ref.value;
        _MiniWorkflowStepLoopNameSize_result
      )
    end,
    "FormatMount" => lambda do
      (
        data_ref = arg_ref(data.value);
        _MiniWorkflowStepFormatMount_result = MiniWorkflowStepFormatMount(
          data_ref
        );
        data.value = data_ref.value;
        _MiniWorkflowStepFormatMount_result
      )
    end,
    "Password"    => lambda do
      (
        data_ref = arg_ref(data.value);
        _MiniWorkflowStepPassword_result = MiniWorkflowStepPassword(
          data_ref
        );
        data.value = data_ref.value;
        _MiniWorkflowStepPassword_result
      )
    end
  }

  sequence = {
    "NameSize"    => { :next => "FormatMount" },
    "FormatMount" => { :next => "Password", :finish => :finish },
    "Password"    => { :finish => :finish }
  }

  # dialog title
  title = _("Add Crypt File")

  widget = MiniWorkflow.Run(
    title,
    StorageIcons.loop_icon,
    aliases,
    sequence,
    "NameSize"
  )

  widget == :finish
end

- (Object) DlgEditLoop(data)



295
296
297
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
325
326
327
328
329
330
331
332
333
334
335
336
# File '../../src/include/partitioning/ep-loop-dialogs.rb', line 295

def DlgEditLoop(data)
  device = Ops.get_string(data.value, "device", "error")

  aliases = {
    "FormatMount" => lambda do
    (
      data_ref = arg_ref(data.value);
      _MiniWorkflowStepFormatMount_result = MiniWorkflowStepFormatMount(
        data_ref
      );
      data.value = data_ref.value;
      _MiniWorkflowStepFormatMount_result
    )
    end,
    "Password" => lambda do
    (
      data_ref = arg_ref(data.value);
      _MiniWorkflowStepPassword_result = MiniWorkflowStepPassword(data_ref);
      data.value = data_ref.value;
      _MiniWorkflowStepPassword_result
    )
    end
  }

  sequence = {
    "FormatMount" => { :next => "Password", :finish => :finish },
    "Password"    => { :finish => :finish }
  }

  # dialog title
  title = Builtins.sformat(_("Edit Crypt File %1"), device)

  widget = MiniWorkflow.Run(
    title,
    StorageIcons.loop_icon,
    aliases,
    sequence,
    "FormatMount"
  )

  widget == :finish
end

- (Object) initialize_partitioning_ep_loop_dialogs(include_target)



28
29
30
# File '../../src/include/partitioning/ep-loop-dialogs.rb', line 28

def initialize_partitioning_ep_loop_dialogs(include_target)
  textdomain "storage"
end

- (Object) MiniWorkflowStepLoopNameSize(data)



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
# File '../../src/include/partitioning/ep-loop-dialogs.rb', line 79

def MiniWorkflowStepLoopNameSize(data)
  Builtins.y2milestone("MiniWorkflowStepLoopNameSize data:%1", data.value)

  min_size_k = 1024
  size_k = Ops.get_integer(data.value, "size_k", 50 * 1024)
  fpath = Ops.get_string(data.value, "fpath", "")
  create_file = Ops.get_boolean(data.value, "create_file", false)

  contents = HVSquash(
    VBox(
      # input field label
      Left(
        MinWidth(
          25,
          InputField(
            Id(:fpath),
            Opt(:hstretch),
            _("Path Name of Loop File"),
            fpath
          )
        )
      ),
      # push button text
      Mode.normal ?
        Left(PushButton(Id(:browse), _("Browse..."))) :
        Empty(),
      VSpacing(0.75),
      # check box text
      term(
        :LeftCheckBoxWithAttachment,
        Id(:create_file),
        Opt(:notify),
        _("Create Loop File"),
        # input field label
        MinWidth(
          15,
          InputField(
            Id(:size),
            Opt(:shrinkable),
            _("Size"),
            Storage.KByteToHumanString(size_k)
          )
        )
      )
    )
  )

  MiniWorkflow.SetContents(
    Greasemonkey.Transform(contents),
    MiniWorkflowStepLoopNameSizeHelptext()
  )
  MiniWorkflow.SetLastStep(false)

  UI.ChangeWidget(Id(:create_file), :Value, create_file)
  UI.ChangeWidget(Id(:size), :Enabled, create_file)

  widget = nil
  begin
    widget = MiniWorkflow.UserInput

    case widget
      when :browse
        @tmp = UI.AskForExistingFile("/", "*", "")
        fpath = @tmp if @tmp != nil
        UI.ChangeWidget(Id(:fpath), :Value, fpath)

        if Mode.normal
          s = Convert.to_integer(SCR.Read(path(".target.size"), fpath))
          create_file = Ops.less_than(s, 0)
          UI.ChangeWidget(Id(:create_file), :Value, create_file)
        end
      when :create_file
        create_file = Convert.to_boolean(
          UI.QueryWidget(Id(:create_file), :Value)
        )
        UI.ChangeWidget(Id(:size), :Enabled, create_file)
      when :next
        fpath = Convert.to_string(UI.QueryWidget(Id(:fpath), :Value))

        if fpath == "" || Builtins.substring(fpath, 0, 1) != "/"
          # popup text
          Popup.Error(
            Builtins.sformat(
              _(
                "The file name \"%1\" is invalid.\nUse an absolute path name.\n"
              ),
              fpath
            )
          )
          widget = :again
          next
        end

        if create_file
          tmp = Convert.to_string(UI.QueryWidget(Id(:size), :Value))
          if !(
              size_k_ref = arg_ref(size_k);
              _HumanStringToKByteWithRangeCheck_result = Storage.HumanStringToKByteWithRangeCheck(
                tmp,
                size_k_ref,
                min_size_k,
                nil
              );
              size_k = size_k_ref.value;
              _HumanStringToKByteWithRangeCheck_result
            )
            # error popup, %1 is replaced by size
            Popup.Error(
              Builtins.sformat(
                _(
                  "The size entered is invalid. Enter a size of at least %1."
                ),
                Storage.KByteToHumanString(min_size_k)
              )
            )
            widget = :again
            next
          end
        else
          s = Convert.to_integer(SCR.Read(path(".target.size"), fpath))
          Builtins.y2milestone("loop file size:%1", s)

          if Mode.normal
            if Ops.less_than(s, 0)
              # popup text
              Popup.Error(
                Builtins.sformat(
                  _(
                    "The file name \"%1\" does not exist\n" +
                      "and the flag for create is off. Either use an existing file or activate\n" +
                      "the create flag."
                  ),
                  fpath
                )
              )
              widget = :again
              next
            else
              size_k = Ops.divide(s, 1024)
            end
          end
        end
    end
  end until widget == :abort || widget == :back || widget == :next

  if widget == :next
    Ops.set(data.value, "fpath", fpath)
    Ops.set(data.value, "create_file", create_file)
    Ops.set(data.value, "size_k", size_k)
  end

  Builtins.y2milestone(
    "MiniWorkflowStepLoopNameSize data:%1 ret:%2",
    data.value,
    widget
  )

  widget
end

- (Object) MiniWorkflowStepLoopNameSizeHelptext



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
# File '../../src/include/partitioning/ep-loop-dialogs.rb', line 32

def MiniWorkflowStepLoopNameSizeHelptext
  # TODO

  # helptext
  helptext = _(
    "\n" +
      "<p><b>Path Name of Loop File:</b><br>This must be an absolute path to the file\n" +
      "containing the data for the encrypted loop device to set up.</p>\n"
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "\n" +
        "<p><b>Create Loop File:</b><br>If this is checked, the file will be created\n" +
        "with the size given in the next field. <b>NOTE:</b> If the file already\n" +
        "exists, all data in it is lost.</p>\n"
    )
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "\n" +
        "<p><b>Size:</b><br>This is the size of the loop file.  The file system\n" +
        "created in the encrypted loop device will have this size.</p>\n"
    )
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "\n" +
        "<p><b>NOTE:</b> During installation, YaST cannot carry out consistency\n" +
        "checks of file size and path names because the file system is not\n" +
        "accessible. It will be created at the end of the installation. Be\n" +
        "careful when providing the size and path name.</p>\n"
    )
  )

  helptext
end