Class: Yast::MediaProposalClient

Inherits:
Client
  • Object
show all
Defined in:
src/clients/media_proposal.rb

Overview

Initialize the installation media.

Instance Method Summary collapse

Instance Method Details

#mainObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'src/clients/media_proposal.rb', line 5

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

  Yast.import "HTML"
  Yast.import "Mode"
  Yast.import "Language"
  Yast.import "Packages"
  Yast.import "PackageCallbacks"

  Yast.import "Installation"

  @func = Convert.to_string(WFM.Args(0))
  @param = Convert.to_map(WFM.Args(1))
  @ret = {}

  if @func == "MakeProposal"
    @force_reset = Ops.get_boolean(@param, "force_reset", false)
    @language_changed = Ops.get_boolean(@param, "language_changed", false)

    UI.OpenDialog(
      Opt(:decorated),
      # intermediate popup while initializing internal packagemanagement
      Label(_("Reading package information..."))
    )

    Packages.Init(true)

    UI.CloseDialog

    @num = Builtins.size(Packages.theSources)
    if Ops.less_or_equal(@num, 0)
      Builtins.y2error("Invalid repository")
      @ret = {
        "warning"       =>
                           # Proposal for system to update, part of the richtext
                           _("No Valid Installation Media"),
        "warning_level" => :blocker
      }
    else
      @tmp = []

      Builtins.foreach(Packages.theSources) do |i|
        new_product = Pkg.SourceProductData(i)
        @tmp = Builtins.add(@tmp, Ops.get_string(new_product, "label", "?"))
      end

      @ret = { "preformatted_proposal" => HTML.List(@tmp) }
    end
  elsif @func == "AskUser"
    @has_next = Ops.get_boolean(@param, "has_next", false)

    # call some function that displays a user dialog
    # or a sequence of dialogs here:
    #
    # sequence = DummyMod::AskUser( has_next );

    @result = Convert.to_symbol(
      WFM.CallFunction("inst_media", [true, @has_next])
    )

    # Fill return map

    @ret = { "workflow_sequence" => @result }
  elsif @func == "Description"
    # Fill return map.
    #
    # Static values do just nicely here, no need to call a function.

    @ret = {
      # this is a heading
      "rich_text_title" => _("Installation Media"),
      # this is a menu entry
      "menu_title"      => _("&Media"),
      "id"              => "media_stuff"
    }
  end

  deep_copy(@ret)
end