Class: DInstaller::DBus::Clients::Software

Inherits:
Base
  • Object
show all
Includes:
WithServiceStatus, WithProgress
Defined in:
lib/dinstaller/dbus/clients/software.rb

Overview

D-Bus client for software configuration

Instance Attribute Summary

Attributes included from WithProgress

#progress

Instance Method Summary collapse

Methods included from WithProgress

#on_progress_change, #on_progress_finish, #start_progress

Methods included from WithServiceStatus

#on_service_status_change, #service_status, #to_service_status

Methods inherited from Base

#service

Constructor Details

#initializeSoftware

Returns a new instance of Software.



37
38
39
40
41
42
43
44
45
# File 'lib/dinstaller/dbus/clients/software.rb', line 37

def initialize
  super

  @dbus_object = service["/org/opensuse/DInstaller/Software1"]
  @dbus_object.introspect

  @dbus_proposal = service["/org/opensuse/DInstaller/Software/Proposal1"]
  @dbus_proposal.introspect
end

Instance Method Details

#add_resolvables(unique_id, type, resolvables, optional: false) ⇒ Object

Add the given list of resolvables to the packages proposal

Parameters:

  • unique_id (String)

    Unique identifier for the resolvables list

  • type (Symbol)

    Resolvables type (:package or :pattern)

  • resolvables (Array<String>)

    Resolvables to add

  • optional (Boolean) (defaults to: false)

    True for optional list, false (the default) for the required list



125
126
127
# File 'lib/dinstaller/dbus/clients/software.rb', line 125

def add_resolvables(unique_id, type, resolvables, optional: false)
  dbus_proposal.AddResolvables(unique_id, TYPES.index(type), resolvables, optional)
end

#available_productsArray<Array<String, String>>

Available products for the installation

Returns:

  • (Array<Array<String, String>>)

    name and display name of each product



55
56
57
58
59
# File 'lib/dinstaller/dbus/clients/software.rb', line 55

def available_products
  dbus_object["org.opensuse.DInstaller.Software1"]["AvailableBaseProducts"].map do |l|
    l[0..1]
  end
end

#finishObject

Finishes the software installation



96
97
98
# File 'lib/dinstaller/dbus/clients/software.rb', line 96

def finish
  dbus_object.Finish
end

#get_resolvables(unique_id, type, optional: false) ⇒ Array<String>

Returns a list of resolvables

Parameters:

  • unique_id (String)

    Unique identifier for the resolvables list

  • type (Symbol)

    Resolvables type (:package or :pattern)

  • optional (Boolean) (defaults to: false)

    True for optional list, false (the default) for the required list

Returns:

  • (Array<String>)

    Resolvables



136
137
138
# File 'lib/dinstaller/dbus/clients/software.rb', line 136

def get_resolvables(unique_id, type, optional: false)
  dbus_proposal.GetResolvables(unique_id, TYPES.index(type), optional).first
end

#installObject

Performs the packages installation



86
87
88
# File 'lib/dinstaller/dbus/clients/software.rb', line 86

def install
  dbus_object.Install
end

#on_product_selected(&block) ⇒ Object

Note:

Signal subscription is done only once. Otherwise, the latest subscription overrides the previous one.

Registers a callback to run when the product changes

Parameters:

  • block (Proc)

    Callback to run when a product is selected



168
169
170
171
172
173
# File 'lib/dinstaller/dbus/clients/software.rb', line 168

def on_product_selected(&block)
  on_properties_change(dbus_object) do |_, changes, _|
    base_product = changes["SelectedBaseProduct"]
    block.call(base_product) unless base_product.nil?
  end
end

#probe(&done) ⇒ Object

Starts the probing process

If a block is given, the method returns immediately and the probing is performed in an asynchronous way.

Parameters:

  • done (Proc)

    Block to execute once the probing is done



81
82
83
# File 'lib/dinstaller/dbus/clients/software.rb', line 81

def probe(&done)
  dbus_object.Probe(&done)
end

#proposeObject

Makes the software proposal



91
92
93
# File 'lib/dinstaller/dbus/clients/software.rb', line 91

def propose
  dbus_object.Propose
end

#provision_selected?(tag) ⇒ Boolean

Determine whether the given tag are provided by the selected packages

Parameters:

  • tag (String)

    Tag to search for (package names, requires/provides, or file names)

Returns:

  • (Boolean)

    true if it is provided; false otherwise



105
106
107
# File 'lib/dinstaller/dbus/clients/software.rb', line 105

def provision_selected?(tag)
  dbus_object.ProvisionSelected(tag)
end

#provisions_selected?(tags) ⇒ Array<Boolean>

Determine whether the given tags are provided by the selected packages

Parameters:

  • tags (Array<String>)

    Tags to search for (package names, requires/provides, or file names)

Returns:

  • (Array<Boolean>)

    An array containing whether each tag is selected or not



114
115
116
# File 'lib/dinstaller/dbus/clients/software.rb', line 114

def provisions_selected?(tags)
  dbus_object.ProvisionsSelected(tags)
end

#remove_resolvables(unique_id, type, resolvables, optional: false) ⇒ Object

Remove resolvables from a list

Parameters:

  • unique_id (String)

    Unique identifier for the resolvables list

  • type (Symbol)

    Resolvables type (:package or :pattern)

  • resolvables (Array<String>)

    Resolvables to remove

  • optional (Boolean) (defaults to: false)

    True for optional list, false (the default) for the required list



158
159
160
# File 'lib/dinstaller/dbus/clients/software.rb', line 158

def remove_resolvables(unique_id, type, resolvables, optional: false)
  dbus_proposal.RemoveResolvables(unique_id, TYPES.index(type), resolvables, optional)
end

#select_product(name) ⇒ Object

Selects the product to install

Parameters:

  • name (String)


71
72
73
# File 'lib/dinstaller/dbus/clients/software.rb', line 71

def select_product(name)
  dbus_object.SelectProduct(name)
end

#selected_productString

Product selected to install

Returns:

  • (String)

    name of the product



64
65
66
# File 'lib/dinstaller/dbus/clients/software.rb', line 64

def selected_product
  dbus_object["org.opensuse.DInstaller.Software1"]["SelectedBaseProduct"]
end

#service_nameString

Returns:

  • (String)


48
49
50
# File 'lib/dinstaller/dbus/clients/software.rb', line 48

def service_name
  @service_name ||= "org.opensuse.DInstaller.Software"
end

#set_resolvables(unique_id, type, resolvables, optional: false) ⇒ Object

Replace a list of resolvables in the packages proposal

Parameters:

  • unique_id (String)

    Unique identifier for the resolvables list

  • type (Symbol)

    Resolvables type (:package or :pattern)

  • resolvables (Array<String>)

    List of resolvables

  • optional (Boolean) (defaults to: false)

    True for optional list, false (the default) for the required list



147
148
149
# File 'lib/dinstaller/dbus/clients/software.rb', line 147

def set_resolvables(unique_id, type, resolvables, optional: false)
  dbus_proposal.SetResolvables(unique_id, TYPES.index(type), resolvables, optional)
end