Class: Yast::StorageClientsClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/StorageClients.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) CommitErrorPopup(error, last_action, extended_message)



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
# File '../../src/modules/StorageClients.rb', line 122

def CommitErrorPopup(error, last_action, extended_message)
  Builtins.y2milestone(
    "CommitErrorPopup error:%1 last_action:%2 extended_message:%3",
    error,
    last_action,
    extended_message
  )

  tmp1 = Builtins.splitstring(extended_message, "\n")
  if Ops.greater_than(Builtins.size(tmp1), 5)
    tmp1 = Builtins.sublist(tmp1, 0, 5)
    tmp1 = Ops.add(tmp1, "...")
  end
  extended_message = Builtins.mergestring(tmp1, "\n")

  text = Ops.add(
    Ops.add(
      _("Failure occurred during the following action:") + "\n",
      last_action
    ),
    "\n\n"
  )

  Builtins.y2milestone("before getErrorString error:%1", error )
  tmp = @sint.getErrorString(error).force_encoding("UTF-8")
  Builtins.y2milestone("before getErrorString ret:%1", tmp )
  text = Ops.add(Ops.add(text, tmp), "\n\n") if !Builtins.isempty(tmp)

  text = Ops.add(
    Ops.add(text, Builtins.sformat(_("System error code was: %1"), error)),
    "\n\n"
  )

  if !Builtins.isempty(extended_message)
    text = Ops.add(Ops.add(text, extended_message), "\n\n")
  end

  text = Ops.add(text, _("Continue despite the error?"))

  ret = Report.ErrorAnyQuestion(
    Popup.NoHeadline,
    text,
    Label.ContinueButton,
    Label.AbortButton,
    :focus_no
  )
  if Mode.autoinst
    ex = Report.Export
    if Ops.get_boolean(ex, ["yesno_messages", "show"], true) == false ||
        Ops.greater_than(
          Ops.get_integer(ex, ["yesno_messages", "timeout"], 0),
          0
        )
      ret = true
    end
  end
  Builtins.y2milestone("CommitErrorPopup ret:%1", ret)
  ret
end

- (Object) EnablePopup



65
66
67
68
69
70
71
72
73
74
75
# File '../../src/modules/StorageClients.rb', line 65

def EnablePopup
  Builtins.y2milestone("EnablePopup")
  @enable_popup = true
  if Ops.greater_than(Builtins.size(@texts), 0)
    Builtins.y2milestone("EnablePopup texts:%1", @texts)
    Builtins.foreach(@texts) { |s| Report.Message(s) }
  end
  @texts = []

  nil
end

- (Object) InfoPopup(text)



99
100
101
102
103
104
105
106
107
108
# File '../../src/modules/StorageClients.rb', line 99

def InfoPopup(text)
  Builtins.y2milestone("InfoPopup enable:%1 txt:%2", @enable_popup, text)
  if @enable_popup
    Report.Message(text)
  else
    @texts = Builtins.add(@texts, text)
  end

  nil
end

- (Object) InstallCallbacks(value)



223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File '../../src/modules/StorageClients.rb', line 223

def InstallCallbacks(value)
  Builtins.y2milestone("InstallCallbacks")

  @sint = value

  StorageCallbacks.ProgressBar("StorageClients::ProgressBar")
  StorageCallbacks.ShowInstallInfo("StorageClients::ShowInstallInfo")
  StorageCallbacks.InfoPopup("StorageClients::InfoPopup")
  StorageCallbacks.YesNoPopup("StorageClients::YesNoPopup")
  StorageCallbacks.CommitErrorPopup("StorageClients::CommitErrorPopup")
  StorageCallbacks.PasswordPopup("StorageClients::PasswordPopup")

  nil
end

- (Object) main



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File '../../src/modules/StorageClients.rb', line 34

def main
  Yast.import "UI"

  Yast.import "Label"
  Yast.import "Mode"
  Yast.import "Popup"
  Yast.import "Report"
  Yast.import "SlideShow"
  Yast.import "StorageCallbacks"

  textdomain "storage"


  @sint = nil


  @enable_popup = false
  @texts = []

  @total_actions = 0
  @current_action = 0
end

- (Object) PasswordPopup(device, attempts, password)



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
# File '../../src/modules/StorageClients.rb', line 183

def PasswordPopup(device, attempts, password)
  Builtins.y2milestone(
    "PasswordPopup device:%1 attempts:%2",
    device,
    attempts
  )

  password = ""

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      Password(
        Id(:password),
        # Label: get password for device
        # Please use newline if label is longer than 40 characters
        Builtins.sformat(_("&Enter Password for Device %1:"), device),
        password
      ),
      ButtonBox(
        PushButton(Id(:ok), Opt(:default), Label.OKButton),
        PushButton(Id(:cancel), Label.CancelButton)
      )
    )
  )

  UI.SetFocus(Id(:password))

  ret = Convert.to_symbol(UI.UserInput)

  if ret == :ok
    password = Convert.to_string(UI.QueryWidget(Id(:password), :Value))
  end

  UI.CloseDialog

  [ret == :ok, password]
end

- (Object) ProgressBar(id, cur, max)



57
58
59
60
61
62
63
# File '../../src/modules/StorageClients.rb', line 57

def ProgressBar(id, cur, max)
  f = Ops.divide(Ops.multiply(100, cur), max)
  SlideShow.SubProgress(f, nil)
  SlideShow.GenericHandleInput

  nil
end

- (Object) ShowInstallInfo(text)



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File '../../src/modules/StorageClients.rb', line 78

def ShowInstallInfo(text)
  SlideShow.SubProgressStart(text)
  SlideShow.AppendMessageToInstLog(text)

  @current_action = Ops.add(@current_action, 1)

  # hack: assume every text change means another action
  Builtins.y2milestone(
    "Current action: %1, total stage progress: %2",
    @current_action,
    Ops.divide(Ops.multiply(@current_action, 100), @total_actions)
  )
  SlideShow.StageProgress(
    Ops.divide(Ops.multiply(@current_action, 100), @total_actions),
    nil
  )

  nil
end

- (Object) YesNoPopup(text)



110
111
112
113
114
115
116
117
118
119
# File '../../src/modules/StorageClients.rb', line 110

def YesNoPopup(text)
  Builtins.y2milestone("YesNoPopup txt:%1", text)
  Report.AnyQuestion(
    Popup.NoHeadline,
    text,
    Label.YesButton,
    Label.NoButton,
    :yes
  )
end