Class: Yast::GPGWidgetsClass
- Inherits:
-
Module
- Object
- Module
- Yast::GPGWidgetsClass
- Defined in:
- ../../src/modules/GPGWidgets.rb
Instance Method Summary (collapse)
-
- (String) AskPassphrasePopup(key)
Ask user to enter the passphrase for the selected gpg key.
-
- (Yast::Term) AskPassphraseTerm
Create a popup window term with the passphrase widget.
-
- (Hash{String => map<String,Object>}) AskPassphraseWidget(key)
Return definition of the passphrase CWM widget.
-
- (Object) CreateNewKey
Get widget description map.
-
- (Object) GpgInitPrivate(key)
Init function of a widget - initialize the private table widget.
-
- (Object) GpgInitPublic(key)
Init function of a widget - initialize the public table widget.
-
- (Array<Yast::Term>) GPGItems(private_keys)
Get list of table items for CWM widget.
-
- (Object) GpgNewKey(key, event)
Refresh the widgets after creating a new gpg key.
-
- (Object) GpgStorePrivate(key, event)
Store the selected private key.
-
- (Object) GpgStorePublic(key, event)
Store the selected public key.
- - (Object) main
-
- (Object) Passphrase
Get the enterd passphrase.
-
- (Object) PassphraseStore(key, event)
Store the passphrase from the widget.
-
- (Object) PrivateKeySelection
Get widget description map.
-
- (Object) PublicKeySelection
Get widget description map.
-
- (String) SelectedPrivateKey
Return the selected private key in the private table widget.
-
- (Object) SetSelectedPrivateKey(keyid)
Set selected private key in the private key table widget.
-
- (Object) SetSelectedPublicKey(keyid)
Set selected public key in the public key table widget.
-
- (Hash{String,map<String => Object>}) Widgets
Return a map with CWM widgets definition.
Instance Method Details
- (String) AskPassphrasePopup(key)
Ask user to enter the passphrase for the selected gpg key. A a popup window is displayed.
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 |
# File '../../src/modules/GPGWidgets.rb', line 373 def AskPassphrasePopup(key) @passphrase = nil if Mode.commandline if CommandLine.Interactive # ask for the passphrase in the commandline (interactive) mode return CommandLine.PasswordInput( Builtins.sformat(_("Enter Passphrase to Unlock GPG Key %1: "), key) ) else # no input possible return nil end end # run the dialog w = CWM.CreateWidgets(["ask_passphrase"], AskPassphraseWidget(key)) contents = AskPassphraseTerm() contents = CWM.PrepareDialog(contents, w) UI.OpenDialog(contents) UI.SetFocus(Id(:passphrase)) CWM.Run(w, {}) UI.CloseDialog @passphrase end |
- (Yast::Term) AskPassphraseTerm
Create a popup window term with the passphrase widget.
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 |
# File '../../src/modules/GPGWidgets.rb', line 342 def AskPassphraseTerm MarginBox( term(:leftMargin, 1), term(:rightMargin, 1), term(:topMargin, 0.2), term(:bottomMargin, 0.5), VBox( HSpacing(50), Heading(_("Enter Passphrase")), "ask_passphrase", VSpacing(0.5), ButtonBox( PushButton( Id(:ok), Opt(:default, :okButton, :key_F10), Label.OKButton ), PushButton( Id(:cancel), Opt(:cancelButton, :key_F9), Label.CancelButton ) ) ) ) end |
- (Hash{String => map<String,Object>}) AskPassphraseWidget(key)
Return definition of the passphrase CWM widget.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File '../../src/modules/GPGWidgets.rb', line 317 def AskPassphraseWidget(key) { "ask_passphrase" => { "widget" => :custom, "custom_widget" => VBox( # text entry Password( Id(:passphrase), Builtins.sformat(_("&Passphrase for GPG Key %1"), key) ) ), "store" => fun_ref( method(:PassphraseStore), "void (string, map)" ), # help text "help" => _( "<p><big><b>Passphrase</b></big><br>\nEnter passphrase to unlock the GPG key." ) } } end |
- (Object) CreateNewKey
Get widget description map
279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File '../../src/modules/GPGWidgets.rb', line 279 def CreateNewKey { "widget" => :push_button, "label" => _("&Create a new GPG key..."), "handle_events" => ["create_new_key"], "handle" => fun_ref(method(:GpgNewKey), "symbol (string, map)"), "help" => _( "<p><big><b>Create a new GPG key</b></big><br>\n" \ "<tt>gpg --gen-key</tt> is started, see <tt>gpg</tt> manual pager for more information.\n" \ "Press Ctrl+C to cancel.\n" \ "</p>" ) } end |
- (Object) GpgInitPrivate(key)
Init function of a widget - initialize the private table widget
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File '../../src/modules/GPGWidgets.rb', line 97 def GpgInitPrivate(key) Builtins.y2milestone("GpgInitPrivate: %1", key) if key == "select_private_key" UI.ChangeWidget(Id(:gpg_priv_table), :Items, GPGItems(true)) if !@_selected_id_private_key.nil? UI.ChangeWidget( Id(:gpg_priv_table), :CurrentItem, @_selected_id_private_key ) end end nil end |
- (Object) GpgInitPublic(key)
Init function of a widget - initialize the public table widget
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File '../../src/modules/GPGWidgets.rb', line 117 def GpgInitPublic(key) Builtins.y2milestone("GpgInitPublic: %1", key) if key == "select_public_key" UI.ChangeWidget(Id(:gpg_public_table), :Items, GPGItems(false)) if !@_selected_id_public_key.nil? UI.ChangeWidget( Id(:gpg_public_table), :CurrentItem, @_selected_id_public_key ) end end nil end |
- (Array<Yast::Term>) GPGItems(private_keys)
Get list of table items for CWM widget.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File '../../src/modules/GPGWidgets.rb', line 75 def GPGItems(private_keys) ret = [] keys = private_keys ? GPG.PrivateKeys : GPG.PublicKeys Builtins.foreach(keys) do |key| uids = Builtins.mergestring(Ops.get_list(key, "uid", []), ", ") ret = Builtins.add( ret, Item( Id(Ops.get_string(key, "id", "")), Ops.get_string(key, "id", ""), uids, Ops.get_string(key, "fingerprint", "") ) ) end deep_copy(ret) end |
- (Object) GpgNewKey(key, event)
Refresh the widgets after creating a new gpg key
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 |
# File '../../src/modules/GPGWidgets.rb', line 248 def GpgNewKey(key, event) event = deep_copy(event) Builtins.y2debug("GpgNewKey: %1, %2", key, event) if key == "create_new_key" GPG.CreateKey # refresh private key widget if it's existing if UI.WidgetExists(Id(:gpg_priv_table)) current = Convert.to_string( UI.QueryWidget(Id(:gpg_priv_table), :CurrentItem) ) UI.ChangeWidget(Id(:gpg_priv_table), :Items, GPGItems(true)) UI.ChangeWidget(Id(:gpg_priv_table), :CurrentItem, current) end # refresh public key widget if it's existing if UI.WidgetExists(Id(:gpg_public_table)) current = Convert.to_string( UI.QueryWidget(Id(:gpg_public_table), :CurrentItem) ) UI.ChangeWidget(Id(:gpg_public_table), :Items, GPGItems(false)) UI.ChangeWidget(Id(:gpg_public_table), :CurrentItem, current) end end nil end |
- (Object) GpgStorePrivate(key, event)
Store the selected private key
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File '../../src/modules/GPGWidgets.rb', line 138 def GpgStorePrivate(key, event) event = deep_copy(event) Builtins.y2debug("GpgStorePrivate: %1, %2", key, event) if key == "select_private_key" @_selected_id_private_key = Convert.to_string( UI.QueryWidget(Id(:gpg_priv_table), :CurrentItem) ) Builtins.y2milestone( "Selected private key: %1", @_selected_id_private_key ) end nil end |
- (Object) GpgStorePublic(key, event)
Store the selected public key
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File '../../src/modules/GPGWidgets.rb', line 158 def GpgStorePublic(key, event) event = deep_copy(event) Builtins.y2debug("GpgStorePublic: %1, %2", key, event) if key == "select_public_key" @_selected_id_public_key = Convert.to_string( UI.QueryWidget(Id(:gpg_public_table), :CurrentItem) ) Builtins.y2milestone( "Selected public key: %1", @_selected_id_public_key ) end nil end |
- (Object) main
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File '../../src/modules/GPGWidgets.rb', line 36 def main Yast.import "UI" Yast.import "Mode" Yast.import "GPG" Yast.import "Label" Yast.import "CWM" Yast.import "CommandLine" textdomain "base" # the selected private key in the private key table @_selected_id_private_key = nil # the selected public key in the public key table @_selected_id_public_key = nil # Passphrase entered in the passphrase widget @passphrase = "" end |
- (Object) Passphrase
Get the enterd passphrase.
310 311 312 |
# File '../../src/modules/GPGWidgets.rb', line 310 def Passphrase @passphrase end |
- (Object) PassphraseStore(key, event)
Store the passphrase from the widget
297 298 299 300 301 302 303 304 305 306 |
# File '../../src/modules/GPGWidgets.rb', line 297 def PassphraseStore(key, event) event = deep_copy(event) Builtins.y2debug("PassphraseStore: %1, %2", key, event) if Ops.get_symbol(event, "WidgetID", :_none) == :ok @passphrase = Convert.to_string(UI.QueryWidget(Id(:passphrase), :Value)) end nil end |
- (Object) PrivateKeySelection
Get widget description map
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 |
# File '../../src/modules/GPGWidgets.rb', line 183 def PrivateKeySelection { "widget" => :custom, "custom_widget" => VBox( Left(Label(Id(:gpg_priv_label), _("GPG Private Keys"))), Table( Id(:gpg_priv_table), # table header - GPG key ID Header( _("Key ID"), # table header - GPG key user ID _("User ID"), # table header - GPG key fingerprint _("Fingerprint") ), # fill up the widget in init handler [] ) ), "init" => fun_ref(method(:GpgInitPrivate), "void (string)"), "store" => fun_ref( method(:GpgStorePrivate), "void (string, map)" ), "help" => _( "<p><big><b>GPG Private Key</b></big><br>\nThe table contains list of the private GPG keys.</p>" ) } end |
- (Object) PublicKeySelection
Get widget description map
215 216 217 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 |
# File '../../src/modules/GPGWidgets.rb', line 215 def PublicKeySelection { "widget" => :custom, "custom_widget" => VBox( Left(Label(_("GPG Public Keys"))), Table( Id(:gpg_public_table), # table header - GPG key ID Header( _("Key ID"), # table header - GPG key user ID _("User ID"), # table header - GPG key fingerprint _("Fingerprint") ), # fill up the widget in init handler [] ) ), "init" => fun_ref(method(:GpgInitPublic), "void (string)"), "store" => fun_ref( method(:GpgStorePublic), "void (string, map)" ), "help" => _( "<p><big><b>GPG Public Key</b></big><br>\nThe table contains list of the public GPG keys.</p>" ) } end |
- (String) SelectedPrivateKey
Return the selected private key in the private table widget
177 178 179 |
# File '../../src/modules/GPGWidgets.rb', line 177 def SelectedPrivateKey @_selected_id_private_key end |
- (Object) SetSelectedPrivateKey(keyid)
Set selected private key in the private key table widget.
58 59 60 61 62 |
# File '../../src/modules/GPGWidgets.rb', line 58 def SetSelectedPrivateKey(keyid) @_selected_id_private_key = keyid nil end |
- (Object) SetSelectedPublicKey(keyid)
Set selected public key in the public key table widget.
66 67 68 69 70 |
# File '../../src/modules/GPGWidgets.rb', line 66 def SetSelectedPublicKey(keyid) @_selected_id_public_key = keyid nil end |
- (Hash{String,map<String => Object>}) Widgets
Return a map with CWM widgets definition. The map contains definitions of all static CWM widgets.
404 405 406 407 408 409 410 |
# File '../../src/modules/GPGWidgets.rb', line 404 def Widgets { "select_private_key" => PrivateKeySelection(), "select_public_key" => PublicKeySelection(), "create_new_key" => CreateNewKey() } end |