Skip to content

Commit

Permalink
remember registered extensions
Browse files Browse the repository at this point in the history
- do not register them again
- disable the checkboxes (extensions cannot be "unregistered")
- display registered status in the main dialog
  • Loading branch information
lslezak committed May 9, 2014
1 parent 18ab0c8 commit eae5fa6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
7 changes: 7 additions & 0 deletions package/yast2-registration.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri May 9 12:27:20 UTC 2014 - lslezak@suse.cz

- remember registered extensions, do not register them again
and disable the checkboxes (extensions cannot be "unregistered")
- display registered status in the main dialog

-------------------------------------------------------------------
Wed May 7 13:17:23 UTC 2014 - lslezak@suse.cz

Expand Down
30 changes: 26 additions & 4 deletions src/clients/inst_scc.rb
Expand Up @@ -190,6 +190,8 @@ def scc_credentials_dialog
info << _("If you skip the registration now be sure to do so in the installed system.")
end

registered = ::Registration::Registration.is_registered?

VBox(
Mode.installation ?
Right(PushButton(Id(:network), _("Network Configuration..."))) :
Expand All @@ -200,7 +202,9 @@ def scc_credentials_dialog
VSpacing(1),
Left(Heading(::Registration::SwMgmt.base_product_label(base_product))),
VSpacing(1),
Label(info)
registered ?
Heading(_("The system is already registered.")) :
Label(info)
)
),
VSpacing(UI.TextMode ? 1 : 2),
Expand All @@ -212,7 +216,7 @@ def scc_credentials_dialog
)
),
VSpacing(UI.TextMode ? 1 : 3),
Mode.normal ? Empty() : PushButton(Id(:skip), _("&Skip Registration")),
registered ? Empty() : PushButton(Id(:skip), _("&Skip Registration")),
VStretch()
)
end
Expand Down Expand Up @@ -272,12 +276,16 @@ def addon_selection_items(addons)
add_extra_spacing = true
end

registered = ::Registration::Storage::Cache.instance.registered_addons

addons.each do |addon|
label = addon.short_name
label << " (#{addon.long_name})" if addon.long_name && !addon.long_name.empty?

box.params << Left(CheckBox(Id(addon.product_ident), Opt(:notify),
addon.short_name, @selected_addons.include?(addon)))
box.params << Left(CheckBox(Id(addon.product_ident),
Opt(:notify),
addon.short_name,
@selected_addons.include?(addon) || registered.include?(addon.product_ident)))

# add extra spacing when there are just few addons, in GUI always
box.params << VSpacing(0.7) if add_extra_spacing
Expand Down Expand Up @@ -401,6 +409,11 @@ def handle_addon_selection_dialog(addons)
when :next
selected = addons.select{|a| UI.QueryWidget(Id(a.product_ident), :Value)}

# ignore already registered addons
selected.reject! do |a|
::Registration::Storage::Cache.instance.registered_addons.include?(a.product_ident)
end

if !supported_addon_count(selected)
ret = nil
next
Expand Down Expand Up @@ -445,6 +458,11 @@ def select_addons
GetInstArgs.enable_next || Mode.normal
)

# disable already registered addons in UI
::Registration::Storage::Cache.instance.registered_addons.each do |addon|
UI.ChangeWidget(Id(addon), :Enabled, false)
end

handle_addon_selection_dialog(addons)
end

Expand Down Expand Up @@ -582,6 +600,10 @@ def register_selected_addons

# select repositories to use in installation (e.g. enable/disable Updates)
select_repositories(product_service) if Mode.installation

# move from selected to registered
::Registration::Storage::Cache.instance.registered_addons << product.product_ident
@selected_addons.reject!{|selected| selected.product_ident == product.product_ident}
end
end

Expand Down
11 changes: 9 additions & 2 deletions src/lib/registration/storage.rb
Expand Up @@ -53,12 +53,19 @@ def initialize
end
end

class Cache < Struct.new(:available_addons, :reg_url, :reg_url_cached)
class Cache < Struct.new(:available_addons, :registered_addons,
:reg_url, :reg_url_cached)

include Singleton

def initialize
# TODO: handle registered addons in installed system
self.registered_addons = []
end
end

# remember the details about SSL verification failure
# the attributes are read from
# the attributes are read from the SSL error context
class SSLErrors < Struct.new(:ssl_error_code, :ssl_error_msg, :ssl_failed_cert)
include Singleton

Expand Down

0 comments on commit eae5fa6

Please sign in to comment.