Module: Yast::CaManagementDialogCaInclude

Defined in:
../../src/include/ca-management/dialog-ca.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) DumbTabs(items, contents)

Faking Tab Widget for NCurses



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File '../../src/include/ca-management/dialog-ca.rb', line 51

def DumbTabs(items, contents)
  items = deep_copy(items)
  contents = deep_copy(contents)
  tabs = HBox()

  Builtins.foreach(items) do |item|
    text = Ops.get_string(item, 1, "")
    idTerm = Ops.get_term(item, 0) { Id(:unknown) }
    tabs = Builtins.add(tabs, PushButton(idTerm, text))
  end

  tabs = Builtins.add(tabs, HStretch())

  Builtins.y2milestone("Creating tabs: %1", tabs)

  VBox(tabs, Frame("", contents))
end

- (Yast::Term) getDialogCATab(tab_id)

Dialog Zone Editor - Tab

Parameters:

  • tab_id (String)

Returns:

  • (Yast::Term)

    dialog for ZoneEditorDialog()



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File '../../src/include/ca-management/dialog-ca.rb', line 73

def getDialogCATab(tab_id)
  if tab_id == "CA"
    return getCATab
  elsif tab_id == "Certificates"
    return getCertificateTab
  elsif tab_id == "CRL"
    return getCRLTab
  elsif tab_id == "Request"
    return getRequestTab
  end
  # This should never happen, but ...
  Builtins.y2error("unknown tab_id: %1", tab_id)
  # When no dialog defined for this tab (software error)
  Label(_("Software error - Unknown Tab"))
end

- (Object) getHelpText(dialog)



103
104
105
106
107
108
109
110
111
112
113
114
# File '../../src/include/ca-management/dialog-ca.rb', line 103

def getHelpText(dialog)
  if dialog == "CA"
    return @CAHelptext
  elsif dialog == "Certificates"
    return @certificateHelptext
  elsif dialog == "CRL"
    return @CRLHelptext
  elsif dialog == "Request"
    return @requestHelptext
  end
  "missing help text"
end

- (Object) handleDialogCATab(dialog, event)



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File '../../src/include/ca-management/dialog-ca.rb', line 122

def handleDialogCATab(dialog, event)
  event = deep_copy(event)
  ret = nil
  if dialog == "CA"
    ret = handleCATab(event)
  elsif dialog == "Certificates"
    ret = handleCertificateTab(event)
  elsif dialog == "CRL"
    ret = handleCRLTab(event)
  elsif dialog == "Request"
    ret = handleRequestTab(event)
  end
  ret
end

- (Object) initDialogCATab(dialog)



89
90
91
92
93
94
95
96
97
98
99
100
101
# File '../../src/include/ca-management/dialog-ca.rb', line 89

def initDialogCATab(dialog)
  if dialog == "CA"
    initCATab
  elsif dialog == "Certificates"
    initCertificateTab
  elsif dialog == "CRL"
    initCRLTab
  elsif dialog == "Request"
    initRequestTab
  end

  nil
end

- (Object) initialize_ca_management_dialog_ca(include_target)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File '../../src/include/ca-management/dialog-ca.rb', line 34

def initialize_ca_management_dialog_ca(include_target)
  textdomain "ca-management"
  Yast.import "CaMgm"
  Yast.import "Label"
  Yast.import "Wizard"
  Yast.import "Popup"
  Yast.import "YaPI::CaManagement"

  Yast.include include_target, "ca-management/util.rb"
  Yast.include include_target, "ca-management/new_cert.rb"
  Yast.include include_target, "ca-management/ca.rb"
  Yast.include include_target, "ca-management/certificate.rb"
  Yast.include include_target, "ca-management/crl.rb"
  Yast.include include_target, "ca-management/request.rb"
end

- (Object) runCADialog

Dialog CA - Main

Returns:

  • (Object)

    dialog result for wizard



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
# File '../../src/include/ca-management/dialog-ca.rb', line 139

def runCADialog
  # Dialog Caption - Expert Settings - Zone Editor
  caption = _("Certificate Authority (CA)")

  current_tab = "CA"

  tab_terms = [
    # Menu Item - CA - Tab
    Item(Id("CA"), _("&Description")),
    # Menu Item - CA - Tab
    Item(Id("Certificates"), _("C&ertificates")),
    # Menu Item - CA - Tab
    Item(Id("CRL"), _("CR&L")),
    # Menu Item - CA - Tab
    Item(Id("Request"), _("&Requests"))
  ]

  contents = VBox(
    Opt(:hvstretch),
    Left(Heading(Ops.add(_("CA Name: "), CaMgm.currentCA))),
    # Here start Tabs
    # FIXME: after `Tab implementation
    UI.HasSpecialWidget(:DumbTab) ?
      DumbTab(
        Id(:dumbtab),
        tab_terms,
        ReplacePoint(Id(:tabContents), getDialogCATab(current_tab))
      ) :
      DumbTabs(
        tab_terms,
        ReplacePoint(Id(:tabContents), getDialogCATab(current_tab))
      )
  )

  # FIXME: Only one help is used for all tabs. Maybe would be better to change the help for every single tab.
  Wizard.SetContentsButtons(
    caption,
    contents,
    getHelpText(current_tab),
    Label.BackButton,
    Label.OKButton
  )
  initDialogCATab(current_tab)

  event = nil
  ret = nil
  while true
    event = UI.WaitForEvent
    ret = Ops.get(event, "ID")

    break if ret == :next
    if ret == :back
      break
    elsif ret == :cancel || ret == :abort
      if Popup.ReallyAbort(true)
        return :abort
      else
        next
      end
    elsif ret == "CA" || ret == "Certificates" || ret == "CRL" ||
        ret == "Request"
      storeDialogCATab(current_tab)
      current_tab = Convert.to_string(ret)

      UI.ReplaceWidget(:tabContents, getDialogCATab(current_tab))
      Wizard.RestoreHelp(getHelpText(current_tab))
      initDialogCATab(current_tab)
    else
      # ensure the same tab selected
      if UI.HasSpecialWidget(:DumbTab)
        UI.ChangeWidget(Id(:dumbtab), :CurrentItem, current_tab)
      end
      ret = handleDialogCATab(current_tab, event)
      if ret == :again
        UI.ReplaceWidget(:tabContents, getDialogCATab(current_tab))
        Wizard.RestoreHelp(getHelpText(current_tab))
        initDialogCATab(current_tab)
      end
    end
  end

  storeDialogCATab(current_tab) if ret == :next

  Convert.to_symbol(ret)
end

- (Object) storeDialogCATab(dialog)



116
117
118
119
120
# File '../../src/include/ca-management/dialog-ca.rb', line 116

def storeDialogCATab(dialog)
  Builtins.y2debug("stroring current Tab")

  nil
end