Class: Yast::PackageCallbacksClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
library/packages/src/modules/PackageCallbacks.rb

Overview

Provides the default Callbacks for Pkg

Constant Summary

CLEAR_PROGRESS_TEXT =

text to clean progress bar in command line

"\b" * 10 + " " * 10 + "\b" * 10
MAX_POPUP_TEXT_SIZE =

max. length of the text in the repository popup window

60
RETRY_TIMEOUT =

base in seconds for automatic retry after a timeout, it will be logarithmic increased upto RETRY_MAX_TIMEOUT

30
RETRY_ATTEMPTS =

number of automatic retries

100
RETRY_MAX_TIMEOUT =

max. retry timeout (15 minutes)

15 * 60
TICK_LABELS =

symbols for ticking in cmd line

["/", "-", "\\", "|"].freeze

Instance Method Summary collapse

Instance Method Details

#AskAbortRefreshObject



1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1639

def AskAbortRefresh
  UI.OpenDialog(
    MarginBox(
      1,
      0.5,
      VBox(
        # a popup question with "Continue", "Skip" and "Abort" buttons
        Label(
          _(
            "The repositories are being refreshed.\n" \
            "Continue with refreshing?\n" \
            "\n" \
            "Note: If the refresh is skipped some packages\n" \
            "might be missing or out of date."
          )
        ),
        ButtonBox(
          PushButton(
            Id(:continue),
            Opt(:default, :okButton),
            Label.ContinueButton
          ),
          # push button label
          PushButton(Id(:skip), Opt(:cancelButton), _("&Skip Refresh"))
        )
      )
    )
  )

  UI.SetFocus(Id(:continue))

  ui = Convert.to_symbol(UI.UserInput)

  UI.CloseDialog

  ui = :continue if ui == :close

  Builtins.y2milestone("User request: %1", ui)

  ui
end

#Authentication(url, msg, username, password) ⇒ Object



2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2201

def Authentication(url, msg, username, password)
  # FIXME: after SLE12 release
  # The following 'if' block is a workaround for bnc#895719 that should be
  # extracted to a proper private method (not sure if it will work as
  # expected being a callback) and adapted to use normal _() instead of
  # dgettext()
  url_query = URI(url).query
  if url_query
    url_params = Hash[URI.decode_www_form(url_query)]
    if url_params.key?("credentials")
      # Seems to be the url of a registration server, so add the tip to msg
      tip = Builtins.dgettext("registration",
        "Check that this system is known to the registration server.")
      msg = "#{tip}\n#{msg}"
    end
  end

  popup = VBox(
    HSpacing(50), # enforce width
    VSpacing(0.1),
    # heading in a popup window
    Heading(_("User Authentication")),
    VSpacing(0.1),
    HBox(
      HSpacing(0.1),
      RichText(
        Opt(:plainText),
        Builtins.sformat(_("URL: %1\n\n%2"), url, msg)
      ),
      HSpacing(0.1)
    ),
    VSpacing(0.1),
    HBox(
      HSpacing(1),
      VBox(
        # textentry label
        InputField(Id(:username), Opt(:hstretch), _("&User Name"), username),
        VSpacing(0.1),
        # textentry label
        Password(Id(:password), Opt(:hstretch), _("&Password"), password)
      ),
      HSpacing(1)
    ),
    VSpacing(0.5),
    ButtonBox(
      PushButton(Id(:cont), Opt(:default, :okButton), Label.ContinueButton),
      PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton)
    ),
    VSpacing(0.5)
  )

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

  ui = Convert.to_symbol(UI.UserInput)

  username = Convert.to_string(UI.QueryWidget(Id(:username), :Value))
  password = Convert.to_string(UI.QueryWidget(Id(:password), :Value))

  UI.CloseDialog

  {
    "username" => username,
    "password" => password,
    "continue" => ui == :cont
  }
end

#ClearDownloadCallbacksObject



1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1877

def ClearDownloadCallbacks
  Pkg.CallbackInitDownload(nil)
  Pkg.CallbackStartDownload(nil)
  Pkg.CallbackProgressDownload(nil)
  Pkg.CallbackDoneDownload(nil)
  Pkg.CallbackDestDownload(nil)
  Pkg.CallbackStartRefresh(nil)
  Pkg.CallbackDoneRefresh(nil)

  nil
end

#ClearScriptCallbacksObject



2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2513

def ClearScriptCallbacks
  Pkg.CallbackScriptStart(nil)
  Pkg.CallbackScriptProgress(nil)
  Pkg.CallbackScriptProblem(nil)
  Pkg.CallbackScriptFinish(nil)

  Pkg.CallbackMessage(nil)

  nil
end

#CloseDownloadProgressPopupObject



1686
1687
1688
1689
1690
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1686

def CloseDownloadProgressPopup
  UI.CloseDialog if IsDownloadProgressPopup()

  nil
end

#CloseSourcePopupObject



1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1020

def CloseSourcePopup
  if !IsSourcePopup()
    Builtins.y2error(
      "The toplevel dialog is not a repository popup dialog!"
    )
    return
  end

  @_source_open = Ops.subtract(@_source_open, 1)

  if @_source_open == 0
    Builtins.y2milestone("Closing repository progress popup")
    UI.CloseDialog
  end
  Builtins.y2milestone("CloseSourcePopup: _source_open: %1", @_source_open)

  nil
end

#DestDownloadObject



1724
1725
1726
1727
1728
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1724

def DestDownload
  CloseDownloadProgressPopup() if !full_screen

  nil
end

#DoneDownload(error_value, error_text) ⇒ Object

just log the status, errors are handled in MediaChange callback



1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1833

def DoneDownload(error_value, error_text)
  if error_value == 0
    Builtins.y2milestone("Download finished")
  elsif @autorefreshing && @autorefreshing_aborted
    Builtins.y2milestone("Refresh aborted")
  else
    Builtins.y2warning(
      "Download failed: error %1: %2",
      error_value,
      error_text
    )
  end

  nil
end

#DonePackage(error, reason) ⇒ Object

After package install.

return "I" for ignore
return "R" for retry
return "C" for abort (not implemented !)


429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'library/packages/src/modules/PackageCallbacks.rb', line 429

def DonePackage(error, reason)
  # remove invalid characters (bnc#876459)
  if !reason.valid_encoding?
    reason.encode!("UTF-16", undef: :replace, invalid: :replace, replace: "?")
    reason.encode!("UTF-8")
    log.warn "Invalid byte sequence found, fixed text: #{reason}"
  end

  UI.CloseDialog if @_package_popup
  @_package_popup = false

  if error != 0
    Builtins.y2milestone(
      "DonePackage(error: %1, reason: '%2')",
      error,
      reason
    )

    message = Builtins.sformat(
      if @_deleting_package
        # error popup during package installation, %1 is the name of the package
        _("Removal of package %1 failed.")
      else
        # error popup during package installation, %1 is the name of the package
        _("Installation of package %1 failed.")
      end,
      @_package_name
    )

    if Mode.commandline
      CommandLine.Print(message)
      CommandLine.Print(reason)

      # ask user in the interactive mode
      if CommandLine.Interactive
        CommandLine.Print("")

        # command line mode - ask user whether installation of the failed package should be retried
        CommandLine.Print(_("Retry installation of the package?"))

        if CommandLine.YesNo
          # return Retry
          return "R"
        end

        # command line mode - ask user whether the installation should be aborted
        CommandLine.Print(_("Abort the installation?"))
        if CommandLine.YesNo
          # return Abort
          return "C"
        end

        # otherwise return Ignore (default)
        return "I"
      end
    else
      button_box = ButtonBox(
        PushButton(Id(:abort), Opt(:cancelButton), Label.AbortButton),
        PushButton(Id(:retry), Opt(:customButton), Label.RetryButton),
        PushButton(Id(:ignore), Opt(:okButton), Label.IgnoreButton)
      )

      if @showLongInfo
        UI.OpenDialog(
          Opt(:decorated),
          layout_popup(message, button_box, true)
        )
        UI.ReplaceWidget(Id(:info), RichText(Opt(:plainText), reason))
      else
        UI.OpenDialog(
          Opt(:decorated),
          layout_popup(message, button_box, false)
        )
        UI.ReplaceWidget(Id(:info), Empty())
      end

      r = nil
      loop do
        r = UI.UserInput
        if r == :show
          @showLongInfo = show_log_info(message, button_box)
          if @showLongInfo
            UI.ReplaceWidget(Id(:info), RichText(Opt(:plainText), reason))
          else
            UI.ReplaceWidget(Id(:info), Empty())
          end
        end
        break if r == :abort || r == :retry || r == :ignore
      end
      Builtins.y2milestone("DonePackage %1", r)

      UI.CloseDialog

      if r == :ignore
        # TODO: add "Don't show again" checkbox
        # a warning popup displayed after pressing [Ignore] after a package installation error
        Popup.Warning(
          _(
            "Ignoring a package failure may result in a broken system.\nThe system should be later verified by running the Software Management module."
          )
        )
      end

      return "C" if r == :abort
      return "R" if r == :retry
    end

  # default: ignore
  else
    # no error, there is additional info (rpm output), see bnc#456446
    Builtins.y2milestone("Additional RPM otput: %1", reason)

    CommandLine.Print(reason) if Mode.commandline
  end

  "I"
end

#DoneProvide(error, reason, name) ⇒ Object

during file providal

*
// return "I" for ignore
// return "R" for retry
// return "C" for abort


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
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
315
316
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
# File 'library/packages/src/modules/PackageCallbacks.rb', line 200

def DoneProvide(error, reason, name)
  Builtins.y2milestone("DoneProvide: %1, %2, %3", error, reason, name)

  if @_provide_popup
    UI.CloseDialog
    @_provide_popup = false
  end

  if Mode.commandline
    # remove the progress
    CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT)
  end

  if @provide_aborted
    @provide_aborted = false
    return "C"
  end

  # INVALID
  if error == 3
    # error message, %1 is a package name
    message = Builtins.sformat(
      _("Package %1 is broken, integrity check has failed."),
      name
    )

    if Mode.commandline
      CommandLine.Print(message)

      # ask user in the interactive mode
      if CommandLine.Interactive
        CommandLine.Print("")

        # command line mode - ask user whether installation of the failed package should be retried
        CommandLine.Print(_("Retry installation of the package?"))

        if CommandLine.YesNo
          # return Retry
          return "R"
        end

        # command line mode - ask user whether the installation should be aborted
        CommandLine.Print(_("Abort the installation?"))
        if CommandLine.YesNo
          # return Abort
          return "C"
        end

        # otherwise return Ignore (default)
        return "I"
      end

      return "I"
    end

    button_box = ButtonBox(
      PushButton(Id(:abort), Opt(:cancelButton, :key_F9), Label.AbortButton),
      PushButton(Id(:retry), Opt(:customButton), Label.RetryButton),
      PushButton(Id(:ignore), Opt(:okButton), Label.IgnoreButton)
    )

    if @showLongInfo
      UI.OpenDialog(
        Opt(:decorated),
        layout_popup(message, button_box, true)
      )
      UI.ReplaceWidget(
        Id(:info),
        RichText(
          Opt(:plainText),
          Ops.add(Builtins.sformat(_("Error: %1:"), error), reason)
        )
      )
    else
      UI.OpenDialog(
        Opt(:decorated),
        layout_popup(message, button_box, false)
      )
      UI.ReplaceWidget(Id(:info), Empty())
    end

    r = nil
    loop do
      r = UI.UserInput
      if r == :show
        @showLongInfo = show_log_info(message, button_box)
        if @showLongInfo
          error_symbol = "ERROR"

          if error == 1
            error_symbol = "NOT_FOUND"
          elsif error == 2
            error_symbol = "IO"
          elsif error == 3
            error_symbol = "INVALID"
          end

          UI.ReplaceWidget(
            Id(:info),
            RichText(
              Opt(:plainText),
              Ops.add(
                # error message, %1 is code of the error,
                # detail string is appended to the end
                Builtins.sformat(_("Error: %1:"), error_symbol),
                reason
              )
            )
          )
        else
          UI.ReplaceWidget(Id(:info), Empty())
        end
      end
      break if r == :abort || r == :retry || r == :ignore
    end

    Builtins.y2milestone("DoneProvide %1", r)

    UI.CloseDialog

    return "C" if r == :abort
    return "R" if r == :retry
    if r == :ignore
      # don't show the warning when a refresh fails
      if !@autorefreshing
        # TODO: add "Don't show again" checkbox
        # a warning popup displayed after pressing [Ignore] after a download error
        Popup.Warning(
          _(
            "Ignoring a download failure may result in a broken system.\nVerify the system later by running the Software Management module.\n"
          )
        )
      end

      return "I"
    end

    Builtins.y2error("Unknown user input: %1", r)
  end

  "I"
end

#DoneScanDb(error, description) ⇒ Object

Callback for finish RPM DB scan event



2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2181

def DoneScanDb(error, description)
  Builtins.y2milestone(
    "RPM DB scan finished: error: %1, reason: '%2'",
    error,
    description
  )

  if Mode.commandline
    # status message (command line mode)
    CommandLine.PrintVerbose(_("RPM database read"))
  elsif @_scan_popup && UI.WidgetExists(Id(:label_scanDB_popup))
    UI.CloseDialog
    @_scan_popup = false
  elsif !full_screen
    Builtins.y2error("The toplevel dialog is not a scan DB popup!")
  end

  nil
end

#EnableAsterixPackage(f) ⇒ Object

Note:

nasty hack for inst_do_net_test client. Remove it when client disappear

Enable or disable StartPackage, ProgressPackage and DonePackage callbacks, but only the progress bar and not the final error message. Returns old value.



347
348
349
350
351
# File 'library/packages/src/modules/PackageCallbacks.rb', line 347

def EnableAsterixPackage(f)
  ret = @enable_asterix_package
  @enable_asterix_package = f
  ret
end

#ErrorScanDb(error, description) ⇒ Object

Callback for error handling during RPM DB scan



2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2090

def ErrorScanDb(error, description)
  Builtins.y2error(
    "ErrorScanDb callback: error: %1, description: %2",
    error,
    description
  )

  # error message, could not read RPM database
  message = _("Initialization of the target failed.")

  if Mode.commandline
    CommandLine.Print(message)
    CommandLine.Print(description)

    # ask user in the interactive mode
    if CommandLine.Interactive
      CommandLine.Print("")

      # command line mode - ask user whether target initializatin can be restarted
      CommandLine.Print(_("Retry?"))

      if CommandLine.YesNo
        # return Retry
        return "R"
      end
    end

    # return Cancel
    return "C"
  end

  show_details = false

  button_box = ButtonBox(
    PushButton(Id(:abort), Opt(:cancelButton), Label.AbortButton),
    PushButton(Id(:retry), Opt(:customButton), Label.RetryButton),
    PushButton(Id(:ignore), Opt(:okButton), Label.IgnoreButton)
  )

  UI.OpenDialog(
    Opt(:decorated),
    layout_popup(message, button_box, false)
  )

  r = nil
  loop do
    r = UI.UserInput
    if r == :show
      show_details = show_log_info(message, button_box)
      if show_details
        error_symbol = "UNKNOWN"

        if error == 0
          error_symbol = "NO_ERROR"
        elsif error == 1
          error_symbol = "FAILED"
        end

        UI.ReplaceWidget(
          Id(:info),
          RichText(
            Opt(:plainText),
            Ops.add(
              # error message, %1 is code of the error,
              # detail string is appended to the end
              Builtins.sformat(_("Error: %1:"), error_symbol),
              description
            )
          )
        )
      else
        UI.ReplaceWidget(Id(:info), Empty())
      end
    end
    break if r == :abort || r == :retry || r == :ignore
  end

  Builtins.y2milestone("ErrorScanDb: user input: %1", r)

  UI.CloseDialog

  return "C" if r == :abort
  return "R" if r == :retry
  return "I" if r == :ignore

  Builtins.y2error("Unknown user input: %1", r)

  "C"
end

#FinishDeltaProvideObject



1459
1460
1461
1462
1463
1464
1465
1466
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1459

def FinishDeltaProvide
  if @_provide_popup
    UI.CloseDialog
    @_provide_popup = false
  end

  nil
end

#FormatPatchName(patch_name, patch_version, patch_arch) ⇒ Object



1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1482

def FormatPatchName(patch_name, patch_version, patch_arch)
  patch_full_name = !patch_name.nil? && patch_name != "" ? patch_name : ""

  if patch_full_name != ""
    if !patch_version.nil? && patch_version != ""
      patch_full_name = Ops.add(
        Ops.add(patch_full_name, "-"),
        patch_version
      )
    end

    if !patch_arch.nil? && patch_arch != ""
      patch_full_name = Ops.add(Ops.add(patch_full_name, "."), patch_arch)
    end
  end

  patch_full_name
end

#InitDownload(task) ⇒ Object



1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1692

def InitDownload(task)
  if !Mode.commandline
    if !full_screen && !IsDownloadProgressPopup()
      # heading of popup
      heading = _("Downloading")

      UI.OpenDialog(
        Opt(:decorated),
        VBox(
          Heading(Id(:download_progress_popup_window), heading),
          VBox(
            HSpacing(60),
            HBox(
              HSpacing(1),
              ProgressBar(Id(:progress), task, 100),
              HSpacing(1)
            ),
            VSpacing(0.5),
            ButtonBox(
              PushButton(Id(:abort), Opt(:cancelButton), Label.AbortButton)
            ),
            VSpacing(0.5)
          )
        )
      )
      UI.ChangeWidget(Id(:progress), :Value, 0)
    end
  end

  nil
end

#InitPackageCallbacksObject

Register package manager callbacks



2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2778

def InitPackageCallbacks
  SetProcessCallbacks()

  SetProvideCallbacks()

  SetPatchCallbacks()

  SetSourceCreateCallbacks()

  SetSourceProbeCallbacks()

  SetSourceReportCallbacks()

  SetProgressReportCallbacks()

  SetFileConflictCallbacks()

  # authentication callback
  Pkg.CallbackAuthentication(
    fun_ref(
      method(:Authentication),
      "map <string, any> (string, string, string, string)"
    )
  )

  # @see bugzilla #183821
  # Do not register these callbacks in case of AutoInstallation
  # And for AutoUpgrade neither (bnc#820166)
  if !(Mode.autoinst || Mode.autoupgrade)
    # Signature-related callbacks
    Pkg.CallbackAcceptUnsignedFile(
      fun_ref(
        SignatureCheckCallbacks.method(:AcceptUnsignedFile),
        "boolean (string, integer)"
      )
    )
    Pkg.CallbackAcceptUnknownGpgKey(
      fun_ref(
        SignatureCheckCallbacks.method(:AcceptUnknownGpgKey),
        "boolean (string, string, integer)"
      )
    )
    # During installation untrusted repositories are disabled to avoid
    # asking again
    gpg_callback = Stage.initial ? :import_gpg_key_or_disable : :ImportGpgKey
    Pkg.CallbackImportGpgKey(
      fun_ref(
        SignatureCheckCallbacks.method(gpg_callback),
        "boolean (map <string, any>, integer)"
      )
    )
    Pkg.CallbackAcceptVerificationFailed(
      fun_ref(
        SignatureCheckCallbacks.method(:AcceptVerificationFailed),
        "boolean (string, map <string, any>, integer)"
      )
    )
    Pkg.CallbackTrustedKeyAdded(
      fun_ref(
        SignatureCheckCallbacks.method(:TrustedKeyAdded),
        "void (map <string, any>)"
      )
    )
    Pkg.CallbackTrustedKeyRemoved(
      fun_ref(
        SignatureCheckCallbacks.method(:TrustedKeyRemoved),
        "void (map <string, any>)"
      )
    )
    Pkg.CallbackAcceptFileWithoutChecksum(
      fun_ref(
        SignatureCheckCallbacks.method(:AcceptFileWithoutChecksum),
        "boolean (string)"
      )
    )
    Pkg.CallbackAcceptWrongDigest(
      fun_ref(
        SignatureCheckCallbacks.method(:AcceptWrongDigest),
        "boolean (string, string, string)"
      )
    )
    Pkg.CallbackAcceptUnknownDigest(
      fun_ref(
        SignatureCheckCallbacks.method(:AcceptUnknownDigest),
        "boolean (string, string)"
      )
    )
  end

  SetMediaCallbacks()

  SetScriptCallbacks()

  SetScanDBCallbacks()

  SetDownloadCallbacks()

  nil
end

#IsDownloadProgressPopupObject



1681
1682
1683
1684
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1681

def IsDownloadProgressPopup
  !Mode.commandline && UI.WidgetExists(Id(:download_progress_popup_window)) &&
    UI.WidgetExists(Id(:progress))
end

#IsProgressPopupObject

is the top level progress popup?



2275
2276
2277
2278
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2275

def IsProgressPopup
  UI.WidgetExists(Id(:progress_widget)) &&
    UI.WidgetExists(Id(:callback_progress_popup))
end

#IsSourcePopupObject

is the top level window source popup?



1007
1008
1009
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1007

def IsSourcePopup
  UI.WidgetExists(Id(:progress)) && UI.WidgetExists(Id(:label_source_popup))
end

#mainObject



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
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
# File 'library/packages/src/modules/PackageCallbacks.rb', line 49

def main
  Yast.import "Pkg"
  Yast.import "UI"

  textdomain "base"

  Yast.import "Directory"
  Yast.import "Label"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "Popup"
  Yast.import "URL"
  Yast.import "CommandLine"
  Yast.import "String"
  Yast.import "Icon"
  Yast.import "Report"
  Yast.import "Wizard"
  Yast.import "Progress"
  Yast.import "FileUtils"
  Yast.import "SignatureCheckCallbacks"
  Yast.import "Linuxrc"

  @_provide_popup = false
  @_package_popup = false
  @_script_popup = false
  @_scan_popup = false
  @_package_name = ""
  @_package_size = 0
  @_deleting_package = false

  @_current_source = 1

  # make showLongInfo module-global so it gets remembered (cf. #14018)
  @showLongInfo = false

  # used to en-/disable StartPackage, ProgressPackage and DonePackage
  @enable_asterix_package = true

  @provide_aborted = false
  @source_aborted = false

  @back_string = "\b\b\b\b\b\b\b\b\b\b"
  @clear_string = Ops.add(Ops.add(@back_string, "          "), @back_string)

  # max. length of the text in the repository popup window
  @max_size = 60

  @autorefreshing = false
  @autorefreshing_aborted = false

  # Location of the persistent storage
  @conf_file = File.join(Directory.vardir, "/package_callbacks.conf")
  @config = nil

  # auto ejecting is in progress
  @doing_eject = false

  # current values for retry functionality
  @retry_url = ""
  @current_retry_timeout = RETRY_TIMEOUT
  @current_retry_attempt = 0

  #=============================================================================
  #	MEDIA CHANGE
  #=============================================================================

  @detected_cd_devices = []

  # reference counter to the open popup window
  @_source_open = 0

  @download_file = ""

  # TODO: use the ID in the prgress popup callbacks,
  # then callbacks may be nested...

  @tick_progress = false
  @val_progress = false
  @current_tick = 0

  # ProgressStart/End events may be nested, remember the types of progresses
  @progress_stack = []

  @last_stage = 0

  @opened_wizard = []

  Builtins.y2milestone("PackageCallbacks constructor")
  InitPackageCallbacks()
end

#MediaChange(error_code, error, url, product, current, current_label, wanted, wanted_label, double_sided, devices, current_device) ⇒ Object


media change callback

if current == -1, show “Ignore”

return “” for ok, retry return “E” for eject media return “I” for ignore bad media return “S” for skip this media return “C” for cancel (not implemented !) return url to change media URL



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
# File 'library/packages/src/modules/PackageCallbacks.rb', line 560

def MediaChange(error_code, error, url, product, current, current_label, wanted, wanted_label, double_sided, devices, current_device)
  devices = deep_copy(devices)
  if @autorefreshing && @autorefreshing_aborted
    Builtins.y2milestone("Refresh aborted")
    return "C"
  end

  Builtins.y2milestone(
    "MediaChange error: err'%1', url'%2', prd'%3', cur'%4'/'%5', wan'%6'/'%7', devs: %8, curr_dev: %9",
    Ops.add(Ops.add(error_code, ":"), error),
    URL.HidePassword(url),
    product,
    current,
    current_label,
    wanted,
    wanted_label,
    devices,
    current_device
  )

  url_scheme = Ops.get_string(URL.Parse(url), "scheme", "").downcase

  # true if it makes sense to offer an eject button (for cd/dvd only ...)
  is_disc = ["cd", "dvd"].include?(url_scheme)

  # do automatic eject
  if is_disc && autoeject && !@doing_eject
    Builtins.y2milestone("Automatically ejecting the medium...")
    @doing_eject = true
    return "E"
  end

  if Builtins.issubstring(error, "ERROR(InstSrc:E_bad_id)")
    error =
      # error report
      _(
        "<p>The repository at the specified URL now provides a different media ID.\n" \
        "If the URL is correct, this indicates that the repository content has changed. To \n" \
        "continue using this repository, start <b>Installation Repositories</b> from \n" \
        "the YaST control center and refresh the repository.</p>\n"
      )
  end

  if wanted_label == ""
    # use only product name for network repository
    # there is no medium 1, 2, ...
    if double_sided
      # media is double sided, we want the user to insert the 'Side A' of the media
      # the complete string will be "<product> <media> <number>, <side>"
      # e.g. "'SuSE Linux 9.0' DVD 1, Side A"
      side = _("Side A")
      if Ops.bitwise_and(wanted, 1) == 0
        # media is double sided, we want the user to insert the 'Side B' of the media
        side = _("Side B")
      end
      wanted = Ops.shift_right(Ops.add(wanted, 1), 1)
      wanted_label = if is_disc
        # label for a repository - %1 product name (e.g. "openSUSE 10.2"), %2 medium number (e.g. 2)
        # %3 side (e.g. "Side A")
        Builtins.sformat("%1 (Disc %2, %3)", product, wanted, side)
      else
        # label for a repository - %1 product name (e.g. "openSUSE 10.2"), %2 medium number (e.g. 2)
        # %3 side (e.g. "Side A")
        Builtins.sformat("%1 (Medium %2, %3)", product, wanted, side)
      end
    else
      wanted_label = if is_disc
        # label for a repository - %1 product name (e.g. openSUSE 10.2), %2 medium number (e.g. 2)
        Builtins.sformat(_("%1 (Disc %2)"), product, wanted)
      else
        # label for a repository - %1 product name (e.g. openSUSE 10.2), %2 medium number (e.g. 2)
        Builtins.sformat(_("%1 (Medium %2)"), product, wanted)
      end
    end
  end

  # prompt to insert product (%1 == "SuSE Linux version 9.2 CD 2")
  message = Builtins.sformat(_("Insert\n'%1'"), wanted_label)
  # with network repository it doesn't make sense to ask for disk
  if url_scheme == "dir"
    # report error while accessing local directory with product (%1 = URL, %2 = "SuSE Linux ...")
    message = Builtins.sformat(
      _(
        "Cannot access installation media\n" \
        "%1\n" \
        "%2.\n" \
        "Check whether the directory is accessible."
      ),
      URL.HidePassword(url),
      wanted_label
    )
  elsif !is_disc
    # report error while accessing network media of product (%1 = URL, %2 = "SuSE Linux ...")
    message = Builtins.sformat(
      _(
        "Cannot access installation media \n" \
        "%1\n" \
        "%2.\n" \
        "Check whether the server is accessible."
      ),
      URL.HidePassword(url),
      wanted_label
    )
  end

  # --------------------------------------
  # build up button box

  button_box = ButtonBox(
    PushButton(Id(:retry), Opt(:default, :okButton), Label.RetryButton)
  )

  if current == -1 # wrong media id, offer "Ignore"
    button_box.params << PushButton(Id(:ignore), Opt(:customButton), Label.IgnoreButton)
  end

  button_box.params << PushButton(
    Id(:cancel),
    Opt(:cancelButton),
    @autorefreshing ? _("Skip Autorefresh") : Label.AbortButton
  )

  # push button label during media change popup, user can skip
  # this media (CD) so no packages from this media will be installed
  button_box.params << PushButton(Id(:skip), Opt(:customButton), _("&Skip"))

  if is_disc
    if !@doing_eject
      @detected_cd_devices = cd_devices(Ops.get(devices, current_device, ""))
    end

    # detect the CD/DVD devices if the ejecting is not in progress,
    # the CD detection closes the ejected tray!
    cds = deep_copy(@detected_cd_devices)

    # display a menu button if there are more CD devices
    if Ops.greater_than(Builtins.size(cds), 1)
      # menu button label - used for more then one device
      button_box = HBox(button_box, MenuButton(_("&Eject"), cds))
    else
      # push button label - in the media change popup, user can eject the CD/DVD
      button_box.params << PushButton(Id(:eject), Opt(:customButton), _("&Eject"))
    end

    button_box = VBox(
      Left(
        CheckBox(
          Id(:auto_eject),
          _("A&utomatically Eject CD or DVD Medium"),
          autoeject
        )
      ),
      button_box
    )
  end

  @doing_eject = false

  # Autoretry code
  doing_auto_retry = false

  if error_code == "IO_SOFT" ||
      Builtins.contains(
        ["ftp", "sftp", "http", "https", "nfs", "smb"],
        url_scheme
      )
    # this a different file, reset the retry counter
    if @retry_url != url
      @retry_url = url
      @current_retry_attempt = 0
    end

    # is the maximum retry count reached?
    if Ops.less_than(@current_retry_attempt, RETRY_ATTEMPTS)
      # reset the counter, use logarithmic back-off with maximum limit
      @current_retry_timeout = if @current_retry_attempt < 10
        RETRY_TIMEOUT * (1 << @current_retry_attempt)
      else
        RETRY_MAX_TIMEOUT
      end

      if Ops.greater_than(@current_retry_timeout, RETRY_MAX_TIMEOUT)
        @current_retry_timeout = RETRY_MAX_TIMEOUT
      end

      button_box = VBox(
        # failed download will be automatically retried after the timeout, %1 = formatted time (MM:SS format)
        Left(Label(Id(:auto_retry), retry_label(@current_retry_timeout))),
        button_box
      )

      doing_auto_retry = true
    else
      Builtins.y2warning(
        "Max. autoretry count (%1) reached, giving up...",
        RETRY_ATTEMPTS
      )
    end
  end

  Builtins.y2milestone("Autoretry: %1", doing_auto_retry)

  if doing_auto_retry
    Builtins.y2milestone("Autoretry attempt: %1", @current_retry_attempt)
  end

  if Mode.commandline
    CommandLine.Print(message)
    CommandLine.Print(error)

    # ask user in the interactive mode
    if CommandLine.Interactive
      CommandLine.Print("")

      # command line mode - ask user whether installation of the failed package should be retried
      CommandLine.Print(_("Retry the installation?"))

      if CommandLine.YesNo
        # return Retry
        return ""
      end

      # command line mode - ask user whether the installation should be aborted
      CommandLine.Print(_("Skip the medium?"))
      if CommandLine.YesNo
        # return Skip
        return "S"
      end

      # otherwise ignore the medium
      CommandLine.Print(_("Ignoring the bad medium..."))
      return "I"
    end

    return "S"
  end

  Builtins.y2debug(
    "Opening Dialog: %1",
    layout_popup(message, button_box, true)
  )

  if @showLongInfo
    UI.OpenDialog(
      Opt(:decorated),
      layout_popup(message, button_box, true)
    )
    # TextEntry label
    UI.ReplaceWidget(
      Id(:info),
      VBox(
        InputField(Id(:url), Opt(:hstretch), _("&URL")),
        RichText(Opt(:plainText), error)
      )
    )
    UI.ChangeWidget(Id(:url), :Value, url)
  else
    UI.OpenDialog(
      Opt(:decorated),
      layout_popup(message, button_box, false)
    )
    UI.ReplaceWidget(Id(:info), Empty())
  end

  # notification
  UI.Beep

  r = nil

  eject_device = ""
  loop do
    r = doing_auto_retry ? UI.TimeoutUserInput(1000) : UI.UserInput

    # timout in autoretry mode?
    if doing_auto_retry
      if r == :timeout
        # decrease timeout counter
        @current_retry_timeout -= 1

        if @current_retry_timeout == 0
          Builtins.y2milestone("The time is out, doing automatic retry...")
          # do the retry
          r = :retry

          @current_retry_attempt += 1
        else
          # popup string - refresh the displayed counter
          UI.ChangeWidget(
            Id(:auto_retry),
            :Label,
            retry_label(@current_retry_timeout)
          )
        end
      else
        # user has pressed a button, reset the retry counter in the next timeout
        Builtins.y2milestone("User input: %1, resetting autoretry url", r)
        @retry_url = ""
      end
    end

    if r == :show
      @showLongInfo = show_log_info(message, button_box)
      if @showLongInfo
        # TextEntry label
        UI.ReplaceWidget(
          Id(:info),
          VBox(
            TextEntry(Id(:url), _("&URL")),
            RichText(Opt(:plainText), error)
          )
        )
        UI.ChangeWidget(Id(:url), :Value, url)
      else
        UI.ReplaceWidget(Id(:info), Empty())
      end
    elsif r == :retry || r == :url
      if @showLongInfo # id(`url) must exist
        newurl = Convert.to_string(UI.QueryWidget(Id(:url), :Value))
        if newurl != url
          url = newurl
          r = :url
        end
      end
    elsif r.is_a?(::String) && r.start_with?("/dev/")
      Builtins.y2milestone("Eject request for %1", r)
      eject_device = r
      r = :eject
    end
    break if [:cancel, :retry, :eject, :skip, :ignore, :url].include?(r)
  end

  # check and save the autoeject configuration if needed
  remember_autoeject if is_disc

  Builtins.y2milestone("MediaChange %1", r)

  UI.CloseDialog

  if @_provide_popup
    UI.CloseDialog
    @_provide_popup = false
  end

  case r
  when :ignore then "I"
  when :skip then "S"
  when :cancel
    # abort during autorefresh should abort complete autorefresh, not only the failed repo
    if @autorefreshing
      @autorefreshing_aborted = true
      Pkg.SkipRefresh
    else
      @provide_aborted = true
    end

    "C"
  when :eject
    @doing_eject = true

    return "E" if eject_device == ""
    # get the index in the list
    dindex = -1

    found = Builtins.find(devices) do |d|
      dindex = Ops.add(dindex, 1)
      d == eject_device
    end

    if found
      Builtins.y2milestone("Device %1 has index %2", eject_device, dindex)
      return "E#{dindex}"
    else
      Builtins.y2warning(
        "Device %1 not found in the list, using default",
        eject_device
      )
      return "E"
    end
  when :url
    Builtins.y2milestone("Redirecting to: %1", URL.HidePassword(url))
    url
  else
    ""
  end
end

#Message(patch_name, patch_version, patch_arch, message) ⇒ Object



1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1624

def Message(patch_name, patch_version, patch_arch, message)
  patch_full_name = FormatPatchName(patch_name, patch_version, patch_arch)
  Builtins.y2milestone("Message (%1): %2", patch_full_name, message)

  if patch_full_name != ""
    # label, %1 is patch name with version and architecture
    patch_full_name = Builtins.sformat(_("Patch: %1\n\n"), patch_full_name)
  end

  ret = Popup.ContinueCancel(Ops.add(patch_full_name, message))
  Builtins.y2milestone("User input: %1", ret)

  ret
end

#NextTickObject



2268
2269
2270
2271
2272
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2268

def NextTick
  @current_tick = (@current_tick + 1) % TICK_LABELS

  nil
end

#NotifyConvertDBObject



2008
2009
2010
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2008

def NotifyConvertDB
  nil
end

#NotifyRebuildDBObject



1938
1939
1940
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1938

def NotifyRebuildDB
  nil
end

#OpenSourcePopupObject



954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
# File 'library/packages/src/modules/PackageCallbacks.rb', line 954

def OpenSourcePopup
  if @_source_open == 0
    UI.OpenDialog(
      VBox(
        HSpacing(MAX_POPUP_TEXT_SIZE),
        Heading(Id(:label_source_popup), Opt(:hstretch), " "),
        ProgressBar(Id(:progress), " ", 100, 0)
      )
    )
  end

  @_source_open = Ops.add(@_source_open, 1)
  Builtins.y2milestone("OpenSourcePopup: _source_open: %1", @_source_open)

  nil
end

#pkg_gpg_check(data) ⇒ String

Handle GPG check result (pkgGpgCheck)

If insecure mode is set to '1', the check result is ignored. Otherwise, no decision is made. When running on an installed system, it always return “”.

Parameters:

  • data (Hash)

    Output from `pkgGpgCheck` callback.

Options Hash (data):

  • "CheckPackageResult" (Integer)

    Check result code according to libzypp.

  • "Package" (String)

    Package's name.

  • "Localpath" (String)

    Path to RPM file.

  • "RepoMediaUrl" (String)

    Media URL.

Returns:

  • (String)

    “I” if the package should be accepted; otherwise a blank string is returned (so no decision is made).



418
419
420
421
422
# File 'library/packages/src/modules/PackageCallbacks.rb', line 418

def pkg_gpg_check(data)
  log.debug("pkgGpgCheck data: #{data}")
  insecure = Stage.initial && Linuxrc.InstallInf("Insecure") == "1"
  insecure ? "I" : ""
end

#ProblemDeltaApply(descr) ⇒ Object



1475
1476
1477
1478
1479
1480
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1475

def ProblemDeltaApply(descr)
  FinishDeltaProvide() # close popup
  Builtins.y2milestone("Failed to apply delta RPM: %1", descr)

  nil
end

#ProblemDeltaDownload(descr) ⇒ Object



1468
1469
1470
1471
1472
1473
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1468

def ProblemDeltaDownload(descr)
  FinishDeltaProvide() # close popup
  Builtins.y2milestone("Failed to download delta RPM: %1", descr)

  nil
end

#ProcessDoneObject

Hander for ProcessDone callback - the process has been finished



2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2472

def ProcessDone
  Builtins.y2milestone("Process: Finished")
  return if Mode.commandline

  idx = Ops.subtract(Builtins.size(@opened_wizard), 1)

  close = Ops.get(@opened_wizard, idx, false)
  @opened_wizard = Builtins.remove(@opened_wizard, idx)

  Builtins.y2milestone(
    "Close Wizard window: %1, new stack: %2",
    close,
    @opened_wizard
  )

  # set 100%
  Progress.Finish

  if close
    Builtins.y2milestone("Closing Wizard window...")
    Wizard.CloseDialog
  end

  nil
end

#ProcessNextStageObject

Hander for ProcessNextStage callback - the current stage has been finished



2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2459

def ProcessNextStage
  Builtins.y2milestone("Setting stage: %1", @last_stage)

  return if Mode.commandline

  Progress.Stage(@last_stage, "", -1)

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

  nil
end

#ProcessProgress(percent) ⇒ Object

Hander for ProcessProgress callback - report total progress

Parameters:

  • percent (Fixnum)

    Total progress in percent



2448
2449
2450
2451
2452
2453
2454
2455
2456
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2448

def ProcessProgress(percent)
  Builtins.y2debug("Process: %1%%", percent)

  return true if Mode.commandline

  Progress.Step(percent)

  true
end

#ProcessStart(task, stages, help) ⇒ Object

Hanler for ProcessStart callback - handle start of a package manager process

Parameters:

  • task (String)

    Decription of the task

  • stages (Array<String>)

    Descriptions of the stages

  • help (String)

    Help text describing the process



2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2406

def ProcessStart(task, stages, help)
  stages = deep_copy(stages)
  Builtins.y2milestone(
    "Process: Start: task: %1, stages: %2, help: %3",
    task,
    stages,
    help
  )
  Builtins.y2milestone(
    "Progress: status: %1, isrunning: %2",
    Progress.status,
    Progress.IsRunning
  )

  return if Mode.commandline

  opened = false

  if Progress.status
    if !Progress.IsRunning
      Builtins.y2milestone("Opening Wizard window...")
      Wizard.CreateDialog
      Wizard.SetDesktopIcon("sw_single")

      opened = true
    end

    # set 100 + number of stages as the max value,
    # Progress module counts stages as extra steps
    Progress.New(task, "", 100 + stages.size, stages, [], help)
    Progress.Title(task)
    @last_stage = 0
  end

  @opened_wizard = Builtins.add(@opened_wizard, opened)
  Builtins.y2milestone("Wizard stack: %1", @opened_wizard)

  nil
end

#ProgressConvertDB(percent, _file) ⇒ Object



1986
1987
1988
1989
1990
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1986

def ProgressConvertDB(percent, _file)
  UI.ChangeWidget(Id(:progress), :Value, percent)

  nil
end

#ProgressDeltaApply(percent) ⇒ Object

redirect ProgressDeltaApply callback (a different signature is required)



189
190
191
192
193
# File 'library/packages/src/modules/PackageCallbacks.rb', line 189

def ProgressDeltaApply(percent)
  ProgressProvide(percent)

  nil
end

#ProgressDownload(percent, bps_avg, bps_current) ⇒ Object



1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1759

def ProgressDownload(percent, bps_avg, bps_current)
  if @autorefreshing && @autorefreshing_aborted
    Builtins.y2milestone("Refresh aborted")
    return false
  end

  if Mode.commandline
    CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT + "#{percent}%")
    if percent == 100
      # sleep for a wile
      Builtins.sleep(200)
      # remove the progress
      CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT)
      # print newline when reached 100%
    end
  else
    msg_rate = ""

    if Ops.greater_than(bps_current, 0)
      # do not show the average download rate if the space is limited
      bps_avg = -1 if textmode && Ops.less_than(display_width, 100)

      format = if textmode
        Ops.add("%1 - ", @download_file)
      else
        Ops.add(@download_file, " - %1")
      end

      # progress bar label, %1 is URL with optional download rate
      msg_rate = Builtins.sformat(
        _("Downloading: %1"),
        String.FormatRateMessage(format, bps_avg, bps_current)
      )
    end

    if full_screen
      Progress.SubprogressValue(percent)

      if Ops.greater_than(Builtins.size(msg_rate), 0)
        Progress.SubprogressTitle(msg_rate)
      end
    else
      UI.ChangeWidget(Id(:progress), :Value, percent)

      if Ops.greater_than(Builtins.size(msg_rate), 0)
        UI.ChangeWidget(Id(:progress), :Label, msg_rate)
      end
    end

    download_aborted = UI.PollInput == :abort

    if download_aborted && @autorefreshing
      # display "Continue", "Skip Refresh" dialog
      answer = AskAbortRefresh()

      if answer == :continue
        download_aborted = false
      elsif answer == :skip
        download_aborted = true
        @autorefreshing_aborted = true

        Pkg.SkipRefresh
      else
        Builtins.y2error("Unknown input value: %1", answer)
      end
    end

    return !download_aborted
  end

  true
end

#ProgressEnd(id) ⇒ Object



2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2333

def ProgressEnd(id)
  Builtins.y2milestone("ProgressFinish: %1", id)

  # remove the last element from the progress stack
  @progress_stack = Builtins.remove(
    @progress_stack,
    Ops.subtract(Builtins.size(@progress_stack), 1)
  )

  if !Mode.commandline && IsProgressPopup()
    UI.CloseDialog if Builtins.size(@progress_stack) == 0
  elsif full_screen
    if Ops.greater_than(Builtins.size(@progress_stack), 0)
      progress_type = Ops.get_symbol(
        @progress_stack,
        [Ops.subtract(Builtins.size(@progress_stack), 1), "type"],
        :none
      )
      task = Ops.get_string(
        @progress_stack,
        [Ops.subtract(Builtins.size(@progress_stack), 1), "task"],
        ""
      )

      Progress.SubprogressType(progress_type, 100)
      Progress.SubprogressTitle(task)
    end
  end

  nil
end

#ProgressPackage(percent) ⇒ Object

During package install.



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'library/packages/src/modules/PackageCallbacks.rb', line 389

def ProgressPackage(percent)
  if @_package_popup
    UI.ChangeWidget(Id(:progress), :Value, percent)
    return UI.PollInput != :abort
  elsif Mode.commandline
    CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT + "#{percent}%")
    if percent == 100
      # sleep for a wile
      Builtins.sleep(200)
      # remove the progress
      CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT)
    end
  end

  true
end

#ProgressProgress(id, val_raw, val_percent) ⇒ Object



2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2365

def ProgressProgress(id, val_raw, val_percent)
  Builtins.y2debug("ProgressProgress: %1, %2%% ", id, val_percent)

  if Mode.commandline
    if @tick_progress
      tick_label = TICK_LABELS[@current_tick]
      CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT + tick_label)
      NextTick()
    else
      CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT + "#{val_percent}%")
    end
  elsif IsProgressPopup()
    if @tick_progress || @val_progress
      UI.ChangeWidget(Id(:progress_widget), :Alive, true)
    else
      UI.ChangeWidget(Id(:progress_widget), :Value, val_percent)
    end

    # aborted ?
    input = UI.PollInput
    if input == :abort
      Builtins.y2warning(
        "Callback %1 has been aborted at %2%% (raw: %3)",
        id,
        val_percent,
        val_raw
      )
      return false
    end
  elsif full_screen
    # fullscreen callbacks
    Progress.SubprogressValue(val_percent)
  end

  true
end

#ProgressProvide(percent) ⇒ Object

during file providal



175
176
177
178
179
180
181
182
183
184
185
186
# File 'library/packages/src/modules/PackageCallbacks.rb', line 175

def ProgressProvide(percent)
  Builtins.y2milestone("ProgressProvide: %1", percent)
  if @_provide_popup
    UI.ChangeWidget(Id(:progress), :Value, percent)
    @provide_aborted = UI.PollInput == :abort
    return !@provide_aborted
  elsif Mode.commandline
    # there is no popup window, but command line mode is set
    CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT + "#{percent}%")
  end
  true
end

#ProgressRebuildDB(percent) ⇒ Object



1916
1917
1918
1919
1920
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1916

def ProgressRebuildDB(percent)
  UI.ChangeWidget(Id(:progress), :Value, percent)

  nil
end

#ProgressScanDb(value) ⇒ Object

Callback for RPM DB scan progress



2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2071

def ProgressScanDb(value)
  if Mode.commandline
    CommandLine.PrintVerboseNoCR(CLEAR_PROGRESS_TEXT + "#{value}%")
  elsif @_scan_popup && UI.WidgetExists(Id(:label_scanDB_popup))
    UI.ChangeWidget(Id(:progress), :Value, value)
    cont = UI.PollInput != :abort

    Builtins.y2warning("Scan DB aborted") if !cont

    return cont
  elsif full_screen
    Progress.Step(value)
  end

  # continue
  true
end

#ProgressStart(id, task, in_percent, is_alive, _min, _max, _val_raw, val_percent) ⇒ Object



2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2280

def ProgressStart(id, task, in_percent, is_alive, _min, _max, _val_raw, val_percent)
  Builtins.y2milestone("ProgressStart: %1", id)

  @tick_progress = is_alive
  @val_progress = !in_percent && !is_alive
  @current_tick = 0

  if Mode.commandline
    CommandLine.Print(task)
  else
    subprogress_type = @tick_progress ? :tick : :progress
    @progress_stack = Builtins.add(
      @progress_stack,
      "type" => subprogress_type, "task" => task
    )

    if IsProgressPopup() &&
        Ops.less_or_equal(Builtins.size(@progress_stack), 1)
      # huh, the popup is already there?
      Builtins.y2warning("Progress popup already opened...")
      UI.CloseDialog
    end

    if full_screen
      Progress.SubprogressType(subprogress_type, 100)
      Progress.SubprogressTitle(task)
    else
      UI.OpenDialog(
        HBox(
          HSpacing(1),
          VBox(
            VSpacing(0.5),
            HSpacing(Id(:callback_progress_popup), MAX_POPUP_TEXT_SIZE),
            if in_percent
              ProgressBar(Id(:progress_widget), task, 100, val_percent)
            else
              BusyIndicator(Id(:progress_widget), task, 3000)
            end,
            VSpacing(0.2),
            ButtonBox(
              PushButton(Id(:abort), Opt(:cancelButton), Label.AbortButton)
            ),
            VSpacing(0.5)
          ),
          HSpacing(1)
        )
      )
    end
  end

  nil
end

#RefreshDoneObject



1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1864

def RefreshDone
  if !Mode.commandline && UI.WidgetExists(Id(:abort))
    UI.ChangeWidget(Id(:abort), :Label, Label.AbortButton)
    UI.RecalcLayout
  end

  Builtins.y2milestone("Autorefresh done")
  @autorefreshing = false
  @autorefreshing_aborted = false

  nil
end

#RefreshStartedObject



1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1849

def RefreshStarted
  Builtins.y2milestone("Autorefreshing repositories...")

  if !Mode.commandline && UI.WidgetExists(Id(:abort))
    # push button label
    UI.ChangeWidget(Id(:abort), :Label, _("Skip Autorefresh"))
    UI.RecalcLayout
  end

  @autorefreshing = true
  @autorefreshing_aborted = false

  nil
end

#RegisterEmptyProgressCallbacksObject

constructor and callback init



2882
2883
2884
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2882

def RegisterEmptyProgressCallbacks
  ::Packages::DummyCallbacks.register
end

#ResetDownloadCallbacksObject



2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2588

def ResetDownloadCallbacks
  Pkg.CallbackInitDownload(nil)
  Pkg.CallbackStartDownload(nil)
  Pkg.CallbackProgressDownload(nil)
  Pkg.CallbackDoneDownload(nil)
  Pkg.CallbackDestDownload(nil)
  Pkg.CallbackStartRefresh(nil)
  Pkg.CallbackDoneRefresh(nil)

  nil
end

#ResetScanDBCallbacksObject



2558
2559
2560
2561
2562
2563
2564
2565
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2558

def ResetScanDBCallbacks
  Pkg.CallbackStartScanDb(nil)
  Pkg.CallbackProgressScanDb(nil)
  Pkg.CallbackErrorScanDb(nil)
  Pkg.CallbackDoneScanDb(nil)

  nil
end

#RestorePatchCallbacksObject



2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2907

def RestorePatchCallbacks
  Pkg.CallbackStartDeltaDownload(nil)
  Pkg.CallbackProgressDeltaDownload(nil)
  Pkg.CallbackProblemDeltaDownload(nil)
  Pkg.CallbackFinishDeltaDownload(nil)

  Pkg.CallbackStartDeltaApply(nil)
  Pkg.CallbackProgressDeltaApply(nil)
  Pkg.CallbackProblemDeltaApply(nil)
  Pkg.CallbackFinishDeltaApply(nil)

  nil
end

#RestorePreviousProgressCallbacksObject



2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2951

def RestorePreviousProgressCallbacks
  RestoreProcessCallbacks()

  RestoreProvideCallbacks()

  RestorePatchCallbacks()

  RestoreSourceCreateCallbacks()

  RestoreSourceReportCallbacks()

  RestoreProgressReportCallbacks()

  ClearScriptCallbacks()

  ResetScanDBCallbacks()

  ResetDownloadCallbacks()

  nil
end

#RestoreProcessCallbacksObject



2886
2887
2888
2889
2890
2891
2892
2893
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2886

def RestoreProcessCallbacks
  Pkg.CallbackProcessStart(nil)
  Pkg.CallbackProcessProgress(nil)
  Pkg.CallbackProcessNextStage(nil)
  Pkg.CallbackProcessDone(nil)

  nil
end

#RestoreProgressReportCallbacksObject



2943
2944
2945
2946
2947
2948
2949
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2943

def RestoreProgressReportCallbacks
  Pkg.CallbackProgressReportStart(nil)
  Pkg.CallbackProgressReportProgress(nil)
  Pkg.CallbackProgressReportEnd(nil)

  nil
end

#RestoreProvideCallbacksObject



2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2895

def RestoreProvideCallbacks
  Pkg.CallbackStartProvide(nil)
  Pkg.CallbackProgressProvide(nil)
  Pkg.CallbackDoneProvide(nil)
  Pkg.CallbackStartPackage(nil)
  Pkg.CallbackProgressPackage(nil)
  Pkg.CallbackDonePackage(nil)
  Pkg.CallbackPkgGpgCheck(nil)

  nil
end

#RestoreSourceCreateCallbacksObject



2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2921

def RestoreSourceCreateCallbacks
  Pkg.CallbackSourceCreateStart(nil)
  Pkg.CallbackSourceCreateProgress(nil)
  Pkg.CallbackSourceCreateError(nil)
  Pkg.CallbackSourceCreateEnd(nil)
  Pkg.CallbackSourceCreateInit(nil)
  Pkg.CallbackSourceCreateDestroy(nil)

  nil
end

#RestoreSourceReportCallbacksObject



2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2932

def RestoreSourceReportCallbacks
  Pkg.CallbackSourceReportStart(nil)
  Pkg.CallbackSourceReportProgress(nil)
  Pkg.CallbackSourceReportError(nil)
  Pkg.CallbackSourceReportEnd(nil)
  Pkg.CallbackSourceReportInit(nil)
  Pkg.CallbackSourceReportDestroy(nil)

  nil
end

#ScriptFinishObject



1616
1617
1618
1619
1620
1621
1622
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1616

def ScriptFinish
  Builtins.y2milestone("ScriptFinish")

  UI.CloseDialog if @_script_popup

  nil
end

#ScriptProblem(description) ⇒ Object



1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1583

def ScriptProblem(description)
  Builtins.y2warning("ScriptProblem: %1", description)

  ui = Popup.AnyQuestion3(
    "", # symbol focus
    description,
    Label.RetryButton, # yes_button_message
    Label.AbortButton, # no_button_message
    Label.IgnoreButton, # retry_button_message
    :retry
  )

  Builtins.y2milestone("Problem result: %1", ui)

  # Abort is the default
  ret = "A"

  if ui == :retry
    # ignore
    ret = "I"
  elsif ui == :yes
    # retry
    ret = "R"
  elsif ui == :no
    # abort
    ret = "A"
  else
    Builtins.y2warning("Unknown result: %1, aborting", ui)
  end

  ret
end

#ScriptProgress(ping, output) ⇒ Object



1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1563

def ScriptProgress(ping, output)
  Builtins.y2milestone("ScriptProgress: ping:%1, output: %2", ping, output)

  if @_script_popup
    if ping
      # TODO: refresh progress indicator
      Builtins.y2debug("-ping-")
    end

    if !output.nil? && output != ""
      # add the output to the log widget
      UI.ChangeWidget(Id(:log), :Value, output)
    end

    input = UI.PollInput
    return false if input == :abort || input == :close
  end
  true
end

#ScriptStart(patch_name, patch_version, patch_arch, script_path) ⇒ Object



1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1501

def ScriptStart(patch_name, patch_version, patch_arch, script_path)
  patch_full_name = FormatPatchName(patch_name, patch_version, patch_arch)

  Builtins.y2milestone(
    "ScriptStart callback: patch: %1, script: %2",
    patch_full_name,
    script_path
  )

  if Mode.commandline
    CommandLine.PrintVerbose(
      Builtins.sformat(
        _("Starting script %1 (patch %2)..."),
        script_path,
        patch_full_name
      )
    )
  else
    progressbox = VBox(
      HSpacing(60),
      # popup heading
      Heading(_("Running Script")),
      VBox(
        if patch_full_name != ""
          HBox(
            # label, patch name follows
            Label(Opt(:boldFont), _("Patch: ")),
            Label(patch_full_name),
            HStretch()
          )
        else
          Empty()
        end,
        HBox(
          # label, script name follows
          Label(Opt(:boldFont), _("Script: ")),
          Label(script_path),
          HStretch()
        )
      ),
      # label
      LogView(Id(:log), _("Output of the Script"), 10, 0),
      ButtonBox(
        PushButton(
          Id(:abort),
          Opt(:default, :key_F9, :cancelButton),
          Label.AbortButton
        )
      )
    )

    UI.CloseDialog if @_script_popup

    UI.OpenDialog(progressbox)
    UI.SetFocus(Id(:abort))

    @_script_popup = true
  end

  nil
end

#SetConvertDBCallbacksObject



2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2012

def SetConvertDBCallbacks
  Pkg.CallbackStartConvertDb(
    fun_ref(method(:StartConvertDB), "void (string)")
  )
  Pkg.CallbackProgressConvertDb(
    fun_ref(method(:ProgressConvertDB), "void (integer, string)")
  )
  Pkg.CallbackStopConvertDb(
    fun_ref(method(:StopConvertDB), "void (integer, string)")
  )
  Pkg.CallbackNotifyConvertDb(fun_ref(method(:NotifyConvertDB), "void ()"))

  nil
end

#SetDownloadCallbacksObject



2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2567

def SetDownloadCallbacks
  Pkg.CallbackInitDownload(fun_ref(method(:InitDownload), "void (string)"))
  Pkg.CallbackStartDownload(
    fun_ref(method(:StartDownload), "void (string, string)")
  )
  Pkg.CallbackProgressDownload(
    fun_ref(
      method(:ProgressDownload),
      "boolean (integer, integer, integer)"
    )
  )
  Pkg.CallbackDoneDownload(
    fun_ref(method(:DoneDownload), "void (integer, string)")
  )
  Pkg.CallbackDestDownload(fun_ref(method(:DestDownload), "void ()"))
  Pkg.CallbackStartRefresh(fun_ref(method(:RefreshStarted), "void ()"))
  Pkg.CallbackDoneRefresh(fun_ref(method(:RefreshDone), "void ()"))

  nil
end

#SetFileConflictCallbacksObject



2773
2774
2775
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2773

def SetFileConflictCallbacks
  ::Packages::FileConflictCallbacks.register
end

#SetHeaderSourcePopup(text) ⇒ Object



971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
# File 'library/packages/src/modules/PackageCallbacks.rb', line 971

def SetHeaderSourcePopup(text)
  # Qt UI uses bold font, the string must be shortened even more
  ui_adjustment = textmode ? 0 : 5

  if Ops.greater_than(
    Builtins.size(text),
    Ops.subtract(MAX_POPUP_TEXT_SIZE, ui_adjustment)
  )
    text = process_message(text, Ops.subtract(MAX_POPUP_TEXT_SIZE, ui_adjustment))
  end

  UI.ChangeWidget(:label_source_popup, :Value, text)
  Builtins.y2milestone("SourcePopup: new header: %1", text)

  nil
end

#SetLabelSourcePopup(text) ⇒ Object



988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
# File 'library/packages/src/modules/PackageCallbacks.rb', line 988

def SetLabelSourcePopup(text)
  # Qt uses proportional font, the string might be longer
  ui_adjustment = textmode ? 0 : 6

  if Ops.greater_than(
    Builtins.size(text),
    Ops.add(MAX_POPUP_TEXT_SIZE, ui_adjustment)
  )
    text = process_message(text, Ops.add(MAX_POPUP_TEXT_SIZE, ui_adjustment))
  end

  # refresh the label in the popup
  UI.ChangeWidget(:progress, :Label, text)
  Builtins.y2milestone("SourcePopup: new label: %1", text)

  nil
end

#SetMediaCallbacksObject

Register callbacks for media change



2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2499

def SetMediaCallbacks
  Pkg.CallbackMediaChange(
    fun_ref(
      method(:MediaChange),
      "string (string, string, string, string, integer, string, integer, string, boolean, list <string>, integer)"
    )
  )
  Pkg.CallbackSourceChange(
    fun_ref(method(:SourceChange), "void (integer, integer)")
  )

  nil
end

#SetPatchCallbacksObject



2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2693

def SetPatchCallbacks
  Pkg.CallbackStartDeltaDownload(
    fun_ref(method(:StartDeltaProvide), "void (string, integer)")
  )
  Pkg.CallbackProgressDeltaDownload(
    fun_ref(method(:ProgressProvide), "boolean (integer)")
  )
  Pkg.CallbackProblemDeltaDownload(
    fun_ref(method(:ProblemDeltaDownload), "void (string)")
  )
  Pkg.CallbackFinishDeltaDownload(
    fun_ref(method(:FinishDeltaProvide), "void ()")
  )

  Pkg.CallbackStartDeltaApply(
    fun_ref(method(:StartDeltaApply), "void (string)")
  )
  Pkg.CallbackProgressDeltaApply(
    fun_ref(method(:ProgressDeltaApply), "void (integer)")
  )
  Pkg.CallbackProblemDeltaApply(
    fun_ref(method(:ProblemDeltaApply), "void (string)")
  )
  Pkg.CallbackFinishDeltaApply(
    fun_ref(method(:FinishDeltaProvide), "void ()")
  )

  nil
end

#SetProcessCallbacksObject



2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2648

def SetProcessCallbacks
  # register process callbacks (total progress)
  Pkg.CallbackProcessStart(
    fun_ref(method(:ProcessStart), "void (string, list <string>, string)")
  )
  Pkg.CallbackProcessProgress(
    fun_ref(method(:ProcessProgress), "boolean (integer)")
  )
  Pkg.CallbackProcessNextStage(
    fun_ref(method(:ProcessNextStage), "void ()")
  )
  Pkg.CallbackProcessDone(fun_ref(method(:ProcessDone), "void ()"))

  nil
end

#SetProgressReportCallbacksObject



2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2753

def SetProgressReportCallbacks
  Pkg.CallbackProgressReportStart(
    fun_ref(
      method(:ProgressStart),
      "void (integer, string, boolean, boolean, integer, integer, integer, integer)"
    )
  )
  Pkg.CallbackProgressReportProgress(
    fun_ref(
      method(:ProgressProgress),
      "boolean (integer, integer, integer)"
    )
  )
  Pkg.CallbackProgressReportEnd(
    fun_ref(method(:ProgressEnd), "void (integer)")
  )

  nil
end

#SetProvideCallbacksObject



2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2664

def SetProvideCallbacks
  Pkg.CallbackStartProvide(
    fun_ref(method(:StartProvide), "void (string, integer, boolean)")
  )
  Pkg.CallbackProgressProvide(
    fun_ref(method(:ProgressProvide), "boolean (integer)")
  )
  Pkg.CallbackDoneProvide(
    fun_ref(method(:DoneProvide), "string (integer, string, string)")
  )
  Pkg.CallbackStartPackage(
    fun_ref(
      method(:StartPackage),
      "void (string, string, string, integer, boolean)"
    )
  )
  Pkg.CallbackProgressPackage(
    fun_ref(method(:ProgressPackage), "boolean (integer)")
  )
  Pkg.CallbackDonePackage(
    fun_ref(method(:DonePackage), "string (integer, string)")
  )
  Pkg.CallbackPkgGpgCheck(
    fun_ref(method(:pkg_gpg_check), "string(map)")
  )

  nil
end

#SetRebuildDBCallbacksObject



1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1942

def SetRebuildDBCallbacks
  Pkg.CallbackStartRebuildDb(fun_ref(method(:StartRebuildDB), "void ()"))
  Pkg.CallbackProgressRebuildDb(
    fun_ref(method(:ProgressRebuildDB), "void (integer)")
  )
  Pkg.CallbackStopRebuildDb(
    fun_ref(method(:StopRebuildDB), "void (integer, string)")
  )
  Pkg.CallbackNotifyRebuildDb(fun_ref(method(:NotifyRebuildDB), "void ()"))

  nil
end

#SetScanDBCallbacksObject



2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2543

def SetScanDBCallbacks
  Pkg.CallbackStartScanDb(fun_ref(method(:StartScanDb), "void ()"))
  Pkg.CallbackProgressScanDb(
    fun_ref(method(:ProgressScanDb), "boolean (integer)")
  )
  Pkg.CallbackErrorScanDb(
    fun_ref(method(:ErrorScanDb), "string (integer, string)")
  )
  Pkg.CallbackDoneScanDb(
    fun_ref(method(:DoneScanDb), "void (integer, string)")
  )

  nil
end

#SetScriptCallbacksObject



2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2524

def SetScriptCallbacks
  Pkg.CallbackScriptStart(
    fun_ref(method(:ScriptStart), "void (string, string, string, string)")
  )
  Pkg.CallbackScriptProgress(
    fun_ref(method(:ScriptProgress), "boolean (boolean, string)")
  )
  Pkg.CallbackScriptProblem(
    fun_ref(method(:ScriptProblem), "string (string)")
  )
  Pkg.CallbackScriptFinish(fun_ref(method(:ScriptFinish), "void ()"))

  Pkg.CallbackMessage(
    fun_ref(method(:Message), "boolean (string, string, string, string)")
  )

  nil
end

#SetSourceCreateCallbacksObject



2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2600

def SetSourceCreateCallbacks
  # source create callbacks
  Pkg.CallbackSourceCreateStart(
    fun_ref(method(:SourceCreateStart), "void (string)")
  )
  Pkg.CallbackSourceCreateProgress(
    fun_ref(method(:SourceCreateProgress), "boolean (integer)")
  )
  Pkg.CallbackSourceCreateError(
    fun_ref(method(:SourceCreateError), "symbol (string, symbol, string)")
  )
  Pkg.CallbackSourceCreateEnd(
    fun_ref(method(:SourceCreateEnd), "void (string, symbol, string)")
  )
  Pkg.CallbackSourceCreateInit(
    fun_ref(method(:SourceCreateInit), "void ()")
  )
  Pkg.CallbackSourceCreateDestroy(
    fun_ref(method(:SourceCreateDestroy), "void ()")
  )

  nil
end

#SetSourceProbeCallbacksObject



2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2624

def SetSourceProbeCallbacks
  # source probing callbacks
  Pkg.CallbackSourceProbeStart(
    fun_ref(method(:SourceProbeStart), "void (string)")
  )
  Pkg.CallbackSourceProbeFailed(
    fun_ref(method(:SourceProbeFailed), "void (string, string)")
  )
  Pkg.CallbackSourceProbeSucceeded(
    fun_ref(method(:SourceProbeSucceeded), "void (string, string)")
  )
  Pkg.CallbackSourceProbeProgress(
    fun_ref(method(:SourceProbeProgress), "boolean (string, integer)")
  )
  Pkg.CallbackSourceProbeError(
    fun_ref(method(:SourceProbeError), "symbol (string, symbol, string)")
  )
  Pkg.CallbackSourceProbeEnd(
    fun_ref(method(:SourceProbeEnd), "void (string, symbol, string)")
  )

  nil
end

#SetSourceReportCallbacksObject



2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2723

def SetSourceReportCallbacks
  # source report callbacks
  Pkg.CallbackSourceReportStart(
    fun_ref(method(:SourceReportStart), "void (integer, string, string)")
  )
  Pkg.CallbackSourceReportProgress(
    fun_ref(method(:SourceReportProgress), "boolean (integer)")
  )
  Pkg.CallbackSourceReportError(
    fun_ref(
      method(:SourceReportError),
      "symbol (integer, string, symbol, string)"
    )
  )
  Pkg.CallbackSourceReportEnd(
    fun_ref(
      method(:SourceReportEnd),
      "void (integer, string, string, symbol, string)"
    )
  )
  Pkg.CallbackSourceReportInit(
    fun_ref(method(:SourceReportInit), "void ()")
  )
  Pkg.CallbackSourceReportDestroy(
    fun_ref(method(:SourceReportDestroy), "void ()")
  )

  nil
end

#SourceChange(source, medianr) ⇒ Object

dummy repository change callback, see SlideShowCallbacks for the real one



947
948
949
950
951
952
# File 'library/packages/src/modules/PackageCallbacks.rb', line 947

def SourceChange(source, medianr)
  Builtins.y2milestone("SourceChange (%1, %2)", source, medianr)
  @_current_source = source

  nil
end

#SourceCreateDestroyObject



1047
1048
1049
1050
1051
1052
1053
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1047

def SourceCreateDestroy
  Builtins.y2milestone("SourceCreateDestroy")

  CloseSourcePopup()

  nil
end

#SourceCreateEnd(url, error, description) ⇒ Object



1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1146

def SourceCreateEnd(url, error, description)
  # set 100% progress
  SourcePopupSetProgress(100)

  Builtins.y2milestone(
    "Source create end: error: url: %1, error: %2, description: %3",
    URL.HidePassword(url),
    error,
    description
  )

  nil
end

#SourceCreateError(url, error, description) ⇒ Object



1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1083

def SourceCreateError(url, error, description)
  Builtins.y2milestone(
    "Source create: error: url: %1, error: %2, description: %3",
    URL.HidePassword(url),
    error,
    description
  )

  # error message - a label followed by a richtext with details
  message = _("An error occurred while creating the repository.")

  if error == :NOT_FOUND
    # error message - a label followed by a richtext with details
    message = _("Unable to retrieve the remote repository description.")
  elsif error == :IO
    # error message - a label followed by a richtext with details
    message = _("An error occurred while retrieving the new metadata.")
  elsif error == :INVALID
    # error message - a label followed by a richtext with details
    message = _("The repository is not valid.")
  elsif error == :REJECTED
    # error message - a label followed by a richtext with details
    message = _("The repository metadata is invalid.")
  end

  if Mode.commandline
    CommandLine.Print(message)
    CommandLine.Print(URL.HidePassword(url))
    CommandLine.Print(description)

    # ask user in the interactive mode
    if CommandLine.Interactive
      CommandLine.Print("")

      # command line mode - ask user whether the repository refreshment should be retried
      CommandLine.Print(_("Retry?"))

      if CommandLine.YesNo
        # return Retry
        return :RETRY
      end
    end

    return :ABORT
  end
  detail = Builtins.sformat("%1<br>%2", url, description)
  UI.OpenDialog(
    VBox(
      Label(message),
      RichText(detail),
      ButtonBox(
        PushButton(Id(:RETRY), Opt(:okButton), Label.RetryButton),
        PushButton(Id(:ABORT), Opt(:cancelButton), Label.AbortButton)
      )
    )
  )
  ret = Convert.to_symbol(UI.UserInput)
  UI.CloseDialog
  Builtins.y2milestone("Source create error: Returning %1", ret)

  ret
end

#SourceCreateInitObject



1039
1040
1041
1042
1043
1044
1045
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1039

def SourceCreateInit
  Builtins.y2milestone("SourceCreateInit")

  OpenSourcePopup()

  nil
end

#SourceCreateProgress(percent) ⇒ Object



1076
1077
1078
1079
1080
1081
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1076

def SourceCreateProgress(percent)
  ret = SourcePopupSetProgress(percent)
  Builtins.y2milestone("SourceCreateProgress(%1) = %2", percent, ret)

  ret
end

#SourceCreateStart(url) ⇒ Object



1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1055

def SourceCreateStart(url)
  Builtins.y2milestone("SourceCreateStart: %1", url)

  # popup label (%1 is repository URL)
  msg = Builtins.sformat(_("Creating Repository %1"), url)

  if Mode.commandline
    CommandLine.Print(msg)
  else
    Builtins.y2milestone("_source_open: %1", @_source_open)

    if @_source_open == 1
      SetHeaderSourcePopup(msg)
    else
      SetLabelSourcePopup(msg)
    end
  end

  nil
end

#SourcePopupSetProgress(value) ⇒ Object



1011
1012
1013
1014
1015
1016
1017
1018
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1011

def SourcePopupSetProgress(value)
  if Ops.greater_than(@_source_open, 0) && IsSourcePopup()
    UI.ChangeWidget(Id(:progress), :Value, value)
    input = UI.PollInput
    return false if input == :abort
  end
  true
end

#SourceProbeEnd(url, error, description) ⇒ Object



1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1275

def SourceProbeEnd(url, error, description)
  CloseSourcePopup()
  CloseSourcePopup()

  Builtins.y2milestone(
    "Source probe end: error: url: %1, error: %2, description: %3",
    URL.HidePassword(url),
    error,
    description
  )

  nil
end

#SourceProbeError(url, error, description) ⇒ Object



1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1210

def SourceProbeError(url, error, description)
  Builtins.y2milestone(
    "Source probe: error: url: %1, error: %2, description: %3",
    URL.HidePassword(url),
    error,
    description
  )

  # error message - a label followed by a richtext with details
  message = _("Error occurred while probing the repository.")

  if error == :NOT_FOUND
    # error message - a label followed by a richtext with details
    message = _("Unable to retrieve the remote repository description.")
  elsif error == :IO
    # error message - a label followed by a richtext with details
    message = _("An error occurred while retrieving the new metadata.")
  elsif error == :INVALID
    # error message - a label followed by a richtext with details
    message = _("The repository is not valid.")
  elsif error == :NO_ERROR
    # error message - a label followed by a richtext with details
    message = _("Repository probing details.")
  elsif error == :REJECTED
    # error message - a label followed by a richtext with details
    message = _("Repository metadata is invalid.")
  end

  if Mode.commandline
    CommandLine.Print(message)
    CommandLine.Print(URL.HidePassword(url))
    CommandLine.Print(description)

    # ask user in the interactive mode
    if CommandLine.Interactive
      CommandLine.Print("")

      # command line mode - ask user whether the repository refreshment should be retried
      CommandLine.Print(_("Retry?"))

      if CommandLine.YesNo
        # return Retry
        return :RETRY
      end
    end

    return :ABORT
  end
  detail = Builtins.sformat("%1<br>%2", url, description)
  UI.OpenDialog(
    VBox(
      Label(message),
      RichText(detail),
      ButtonBox(
        PushButton(Id(:RETRY), Opt(:okButton), Label.RetryButton),
        PushButton(Id(:ABORT), Opt(:cancelButton), Label.AbortButton)
      )
    )
  )
  ret = Convert.to_symbol(UI.UserInput)
  UI.CloseDialog
  Builtins.y2milestone("Source probe error: Returning %1", ret)
  ret
end

#SourceProbeFailed(url, type) ⇒ Object



1186
1187
1188
1189
1190
1191
1192
1193
1194
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1186

def SourceProbeFailed(url, type)
  Builtins.y2milestone(
    "Repository %1 is not %2 repository",
    URL.HidePassword(url),
    type
  )

  nil
end

#SourceProbeProgress(_url, value) ⇒ Object



1206
1207
1208
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1206

def SourceProbeProgress(_url, value)
  SourcePopupSetProgress(value)
end

#SourceProbeStart(url) ⇒ Object



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1160

def SourceProbeStart(url)
  Builtins.y2milestone("SourceProbeStart: %1", URL.HidePassword(url))

  # popup label (%1 is repository URL)
  msg = Builtins.sformat(_("Probing Repository %1"), URL.HidePassword(url))

  if Mode.commandline
    CommandLine.Print(msg)
  else
    OpenSourcePopup()

    msg2 = Builtins.sformat(
      _("Probing Repository %1"),
      URL.HidePassword(url)
    )

    if @_source_open == 1
      SetHeaderSourcePopup(msg2)
    else
      SetLabelSourcePopup(msg2)
    end
  end

  nil
end

#SourceProbeSucceeded(url, type) ⇒ Object



1196
1197
1198
1199
1200
1201
1202
1203
1204
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1196

def SourceProbeSucceeded(url, type)
  Builtins.y2milestone(
    "Repository %1 is type %2",
    URL.HidePassword(url),
    type
  )

  nil
end

#SourceReportDestroyObject



1403
1404
1405
1406
1407
1408
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1403

def SourceReportDestroy
  Builtins.y2milestone("Source report destroy")
  CloseSourcePopup()

  nil
end

#SourceReportEnd(src_id, url, task, error, description) ⇒ Object



1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1380

def SourceReportEnd(src_id, url, task, error, description)
  Builtins.y2milestone(
    "Source report end: src: %1, url: %2, task: %3, error: %4, description: %5",
    src_id,
    URL.HidePassword(url),
    task,
    error,
    description
  )

  # set 100% progress
  SourcePopupSetProgress(100)

  nil
end

#SourceReportError(source_id, url, error, description) ⇒ Object



1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1319

def SourceReportError(source_id, url, error, description)
  Builtins.y2milestone(
    "Source report: error: id: %1, url: %2, error: %3, description: %4",
    source_id,
    URL.HidePassword(url),
    error,
    description
  )

  # error message - a label followed by a richtext with details
  message = Builtins.sformat(_("Repository %1"), url)

  if error == :NOT_FOUND
    # error message - a label followed by a richtext with details
    message = _("Unable to retrieve the remote repository description.")
  elsif error == :IO
    # error message - a label followed by a richtext with details
    message = _("An error occurred while retrieving the new metadata.")
  elsif error == :INVALID
    # error message - a label followed by a richtext with details
    message = _("The repository is not valid.")
  end

  if Mode.commandline
    CommandLine.Print(message)
    CommandLine.Print(url)
    CommandLine.Print(description)

    # ask user in the interactive mode
    if CommandLine.Interactive
      CommandLine.Print("")

      # command line mode - ask user whether the repository refreshment should be retried
      CommandLine.Print(_("Retry?"))

      if CommandLine.YesNo
        # return Retry
        return :RETRY
      end
    end

    return :ABORT
  end
  detail = Builtins.sformat("%1<br>%2", url, description)
  UI.OpenDialog(
    VBox(
      Label(message),
      RichText(detail),
      HBox(
        PushButton(Id(:RETRY), Opt(:okButton), Label.RetryButton),
        PushButton(Id(:ABORT), Opt(:cancelButton), Label.AbortButton)
      )
    )
  )
  ret = Convert.to_symbol(UI.UserInput)
  UI.CloseDialog
  Builtins.y2milestone("Source report error: Returning %1", ret)

  ret
end

#SourceReportInitObject



1396
1397
1398
1399
1400
1401
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1396

def SourceReportInit
  Builtins.y2milestone("Source report init")
  OpenSourcePopup()

  nil
end

#SourceReportProgress(value) ⇒ Object



1312
1313
1314
1315
1316
1317
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1312

def SourceReportProgress(value)
  ret = SourcePopupSetProgress(value)
  Builtins.y2debug("SourceReportProgress(%1) = %2", value, ret)

  ret
end

#SourceReportStart(source_id, url, task) ⇒ Object



1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1289

def SourceReportStart(source_id, url, task)
  Builtins.y2milestone(
    "Source report start: src: %1, URL: %2, task: %3",
    source_id,
    URL.HidePassword(url),
    task
  )

  if Mode.commandline
    CommandLine.Print(task)
  else
    Builtins.y2milestone("_source_open: %1", @_source_open)

    if @_source_open == 1
      SetHeaderSourcePopup(task)
    else
      SetLabelSourcePopup(task)
    end
  end

  nil
end

#StartConvertDB(_unused1) ⇒ Object



1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1955

def StartConvertDB(_unused1)
  # heading of popup
  heading = _("Checking Package Database")

  # message in a progress popup
  message = _(
    "Converting package database. This process can take some time."
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      Heading(heading),
      VBox(
        Label(message),
        HSpacing(60),
        HBox(
          HSpacing(2),
          ProgressBar(Id(:progress), _("Status"), 100),
          HSpacing(2)
        ),
        VSpacing(1)
      )
    )
  )

  UI.ChangeWidget(Id(:progress), :Value, 0)

  nil
end

#StartDeltaApply(name) ⇒ Object

at start of delta application



1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1435

def StartDeltaApply(name)
  if Mode.commandline
    CommandLine.PrintVerbose(
      Builtins.sformat(_("Applying delta RPM package %1..."), name)
    )
  else
    # popup heading
    progressbox = VBox(
      HSpacing(40),
      # popup heading
      Heading(_("Applying delta RPM package")),
      Left(
        HBox(Left(Label(Opt(:boldFont), _("Package: "))), Left(Label(name)))
      ),
      ProgressBar(Id(:progress), "", 100, 0)
    )
    UI.CloseDialog if @_provide_popup
    UI.OpenDialog(progressbox)
    @_provide_popup = true
  end

  nil
end

#StartDeltaProvide(name, archivesize) ⇒ Object

at start of delta providal



1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1412

def StartDeltaProvide(name, archivesize)
  sz = String.FormatSizeWithPrecision(archivesize, 2, false)
  if Mode.commandline
    CommandLine.PrintVerbose(
      Builtins.sformat(
        _("Downloading delta RPM package %1 (%2)..."),
        name,
        sz
      )
    )
  else
    UI.CloseDialog if @_provide_popup
    # popup heading
    providebox = progress_box(_("Downloading Delta RPM package"), name, sz)
    UI.OpenDialog(providebox)
    @_provide_popup = true
  end

  nil
end

#StartDownload(url, localfile) ⇒ Object



1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1730

def StartDownload(url, localfile)
  Builtins.y2milestone(
    "Downloading %1 to %2",
    URL.HidePassword(url),
    localfile
  )

  # reformat the URL
  url_report = URL.FormatURL(URL.Parse(URL.HidePassword(url)), MAX_POPUP_TEXT_SIZE)
  # remember the URL
  @download_file = url_report

  # message in a progress popup
  message = Builtins.sformat(_("Downloading: %1"), url_report)

  if Mode.commandline
    CommandLine.PrintVerbose(message)
  elsif IsDownloadProgressPopup()
    # change the label
    UI.ChangeWidget(Id(:progress), :Label, message)
    UI.ChangeWidget(Id(:progress), :Value, 0)
  elsif full_screen
    Progress.SubprogressType(:progress, 100)
    Progress.SubprogressTitle(message)
  end

  nil
end

#StartPackage(name, _location, _summary, installsize, is_delete) ⇒ Object

At start of package install.



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
384
385
386
# File 'library/packages/src/modules/PackageCallbacks.rb', line 354

def StartPackage(name, _location, _summary, installsize, is_delete)
  return if !@enable_asterix_package

  @_package_name = name
  @_package_size = installsize
  @_deleting_package = is_delete
  sz = String.FormatSizeWithPrecision(installsize, 2, false)

  if Mode.commandline
    CommandLine.PrintVerbose(
      Builtins.sformat(
        if is_delete
          _("Uninstalling package %1 (%2)...")
        else
          _("Installing package %1 (%2)...")
        end,
        @_package_name,
        sz
      )
    )
  else
    packagebox = progress_box(
      is_delete ? _("Uninstalling Package") : _("Installing Package"),
      @_package_name,
      sz
    )

    UI.OpenDialog(Opt(:decorated), packagebox)
    @_package_popup = true
  end

  nil
end

#StartProvide(name, archivesize, remote) ⇒ Object

at start of file providal



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
# File 'library/packages/src/modules/PackageCallbacks.rb', line 145

def StartProvide(name, archivesize, remote)
  Builtins.y2milestone("StartProvide: name: %1, remote: %2", name, remote)
  if remote
    sz = String.FormatSizeWithPrecision(archivesize, 2, false)
    if Mode.commandline
      CommandLine.PrintVerbose(
        Builtins.sformat(_("Downloading package %1 (%2)..."), name, sz)
      )
    else
      UI.CloseDialog if @_provide_popup

      if full_screen
        Progress.SubprogressType(:progress, 100)
        Progress.SubprogressTitle(
          Builtins.sformat(_("Downloading package %1 (%2)..."), name, sz)
        )
      else
        # popup heading
        providebox = progress_box(_("Downloading Package"), name, sz)
        UI.OpenDialog(providebox)
        @_provide_popup = true
      end
    end
  end

  nil
end

#StartRebuildDBObject



1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1889

def StartRebuildDB
  # heading of popup
  heading = _("Checking Package Database")

  # message in a progress popup
  message = _(
    "Rebuilding package database. This process can take some time."
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      Heading(heading),
      VBox(
        Label(message),
        HSpacing(60),
        HBox(HSpacing(2), ProgressBar(Id(:progress), "", 100), HSpacing(2)),
        VSpacing(1)
      )
    )
  )

  UI.ChangeWidget(Id(:progress), :Value, 0)

  nil
end

#StartScanDbObject

Callback for start RPM DB scan event



2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
# File 'library/packages/src/modules/PackageCallbacks.rb', line 2028

def StartScanDb
  Builtins.y2milestone("Scanning RPM DB...")

  if Mode.commandline
    # progress message (command line mode)
    CommandLine.PrintVerbose(_("Reading RPM database..."))
  elsif !full_screen
    UI.OpenDialog(
      VBox(
        HSpacing(60),
        # popup heading
        Heading(
          Id(:label_scanDB_popup),
          Opt(:hstretch),
          _("Reading Installed Packages")
        ),
        HBox(
          # progress bar label
          ProgressBar(
            Id(:progress),
            _("Scanning RPM database..."),
            100,
            0
          ), # TODO: allow Abort
          # 			,
          # 			`VBox(
          # 			    `Label(""),
          # 			    `PushButton(`id(`abort), Label::AbortButton())
          # 			)
          HSpacing(1)
        )
      )
    )

    @_scan_popup = true
  else
    Progress.Title(_("Scanning RPM database..."))
  end

  nil
end

#StopConvertDB(error_value, error_text) ⇒ Object



1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1992

def StopConvertDB(error_value, error_text)
  if error_value != 0
    # error message, %1 is the cause for the error
    Popup.Error(
      Builtins.sformat(
        _("Conversion of package database failed:\n%1"),
        error_text
      )
    )
  end

  UI.CloseDialog

  nil
end

#StopRebuildDB(error_value, error_text) ⇒ Object



1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
# File 'library/packages/src/modules/PackageCallbacks.rb', line 1922

def StopRebuildDB(error_value, error_text)
  if error_value != 0
    # error message, %1 is the cause for the error
    Popup.Error(
      Builtins.sformat(
        _("Rebuilding of package database failed:\n%1"),
        error_text
      )
    )
  end

  UI.CloseDialog

  nil
end