Class: Yast::ProductLicenseClass
- Inherits:
-
Module
- Object
- Module
- Yast::ProductLicenseClass
- Includes:
- Logger
- Defined in:
- src/modules/ProductLicense.rb,
src/modules/ProductLicense.rb
Overview
Provide access / dialog for product license
Constant Summary collapse
- DOWNLOAD_URL_SCHEMA =
["http", "https", "ftp"].freeze
- README_BETA =
"/README.BETA".freeze
- DEFAULT_FALLBACK_LANGUAGES =
["en_US", "en"].freeze
Instance Attribute Summary collapse
-
#license_file_print ⇒ Object
Returns the value of attribute license_file_print.
-
#license_patterns ⇒ Object
Returns the value of attribute license_patterns.
Instance Method Summary collapse
-
#AcceptanceNeeded(id) ⇒ Boolean
Returns whether accepting the license manually is required.
- #AskAddOnLicenseAgreement(src_id) ⇒ Object
- #AskFirstStageLicenseAgreement(src_id, action) ⇒ Object
- #AskInstalledLicenseAgreement(directory, action) ⇒ Object
-
#AskInstalledLicensesAgreement(directories, action) ⇒ Object
FATE #306295: More licenses in one dialog.
-
#AskLicenseAgreement(src_id, dir, _patterns, action, enable_back, base_product, require_agreement, id) ⇒ Object
Ask user to confirm license agreement.
-
#AskLicensesAgreement(dirs, patterns, action, enable_back, base_product, require_agreement) ⇒ Object
Ask user to confirm license agreement.
- #AskLicensesAgreementWithHeading(dirs, _patterns, action, enable_back, base_product, require_agreement, caption, heading) ⇒ Object
-
#CleanUp ⇒ Object
Generic cleanup.
-
#DisplayLicenseDialogWithTitle(languages, back, license_language, licenses, id, caption) ⇒ Object
FIXME: this is needed only by yast2-registration, fix it later and make this method private.
-
#GetLicenseDialogHelp ⇒ Object
Help text for asking license for product.
-
#HandleLicenseDialogRet(licenses, base_product, action) ⇒ Object
FIXME: this is needed only by yast2-registration, fix it later and make this method private.
-
#initialize_default_values ⇒ Object
(Re)Initializes all internal caches.
- #main ⇒ Object
-
#SetAcceptanceNeeded(id, new_value) ⇒ Object
Sets whether explicit acceptance of a license is needed.
-
#ShowFullScreenLicenseInInstallation(replace_point_ID, src_id) ⇒ Object
Called from the first stage Welcome dialog by clicking on a button.
-
#ShowLicenseInInstallation(replace_point_ID, src_id) ⇒ Object
Used in the first-stage Welcome dialog.
Instance Attribute Details
#license_file_print ⇒ Object
Returns the value of attribute license_file_print
9 10 11 |
# File 'src/modules/ProductLicense.rb', line 9 def license_file_print @license_file_print end |
#license_patterns ⇒ Object
Returns the value of attribute license_patterns
9 10 11 |
# File 'src/modules/ProductLicense.rb', line 9 def license_patterns @license_patterns end |
Instance Method Details
#AcceptanceNeeded(id) ⇒ Boolean
Returns whether accepting the license manually is required.
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 |
# File 'src/modules/ProductLicense.rb', line 88 def AcceptanceNeeded(id) # FIXME: lazy loading of the info about licenses, bigger refactoring needed # @see bsc#993285 # # In the initial installation, for base product, acceptance_needed needs # to be known before showing the license dialog (inst_complex_welcome). # Loading the info is handled internally in other cases. # # id can be a string (currently is) when called from inst_complex_welcome if !@license_acceptance_needed.key?(id) && Stage.initial && id.to_s == base_product_id.to_s # Although we know the base product ID, the function below expects # id to be nil for base product in inital installation GetSourceLicenseDirectory(nil, "/") cache_license_acceptance_needed(id, @license_dir) end if @license_acceptance_needed.key?(id) @license_acceptance_needed[id] else log.warn "SetAcceptanceNeeded(#{id}) should be called first, using default 'true'" true end end |
#AskAddOnLicenseAgreement(src_id) ⇒ Object
405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'src/modules/ProductLicense.rb', line 405 def AskAddOnLicenseAgreement(src_id) AskLicenseAgreement( src_id, "", @license_patterns, "abort", # back button is disabled false, false, false, Builtins.tostring(src_id) ) end |
#AskFirstStageLicenseAgreement(src_id, action) ⇒ Object
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'src/modules/ProductLicense.rb', line 419 def AskFirstStageLicenseAgreement(src_id, action) # bug #223258 # disabling back button when the select-language dialog is skipped # enable_back = true enable_back = false if Language.selection_skipped AskLicenseAgreement( nil, "", @license_patterns, action, # back button is enabled enable_back, true, true, # unique id Builtins.tostring(src_id) ) end |
#AskInstalledLicenseAgreement(directory, action) ⇒ Object
540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'src/modules/ProductLicense.rb', line 540 def AskInstalledLicenseAgreement(directory, action) # patterns are hard-coded AskLicenseAgreement( nil, directory, [], action, false, true, false, directory ) end |
#AskInstalledLicensesAgreement(directories, action) ⇒ Object
FATE #306295: More licenses in one dialog
555 556 557 558 559 |
# File 'src/modules/ProductLicense.rb', line 555 def AskInstalledLicensesAgreement(directories, action) directories = deep_copy(directories) # patterns are hard-coded AskLicensesAgreement(directories, [], action, false, true, false) end |
#AskLicenseAgreement(src_id, dir, _patterns, action, enable_back, base_product, require_agreement, id) ⇒ Object
Ask user to confirm license agreement
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 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 |
# File 'src/modules/ProductLicense.rb', line 162 def AskLicenseAgreement(src_id, dir, _patterns, action, enable_back, base_product, require_agreement, id) @lic_lang = "" licenses = {} available_langs = [] license_ident = "" init_ret = ( licenses_ref = arg_ref(licenses) available_langs_ref = arg_ref(available_langs) license_ident_ref = arg_ref(license_ident) result = InitLicenseData( src_id, dir, licenses_ref, available_langs_ref, require_agreement, license_ident_ref, id ) licenses = licenses_ref.value available_langs = available_langs_ref.value license_ident = license_ident_ref.value result ) if init_ret == :auto || init_ret == :accepted Builtins.y2milestone("Returning %1", init_ret) return init_ret end created_new_dialog = false # #459391 # If a progress is running open another dialog if Progress.IsRunning Builtins.y2milestone( "Some progress is running, opening new dialog for license..." ) Wizard.OpenLeftTitleNextBackDialog created_new_dialog = true end licenses_ref = arg_ref(licenses) title = _("License Agreement") if src_id repo_data = Pkg::SourceGeneralData(src_id) if repo_data label = repo_data["name"] # TRANSLATORS: %s is an extension name # e.g. "SUSE Linux Enterprise Software Development Kit" title = _("%s License Agreement") % label unless label.empty? end end DisplayLicenseDialogWithTitle( available_langs, # license id enable_back, @lic_lang, licenses_ref, id, title ) licenses = licenses_ref.value update_license_archive_location(src_id) if src_id # Display beta file as a popup if exists InstShowInfo.show_info_txt(@beta_file) if !@beta_file.nil? # initial loop licenses_ref = arg_ref(licenses) ret = HandleLicenseDialogRet( licenses_ref, base_product, action ) if ret == :accepted && !license_ident.nil? # store already accepted license ID LicenseHasBeenAccepted(license_ident) end CleanUpLicense(@tmpdir) # bugzilla #303922 Wizard.CloseDialog if created_new_dialog || !Stage.initial && !src_id.nil? CleanUp() ret end |
#AskLicensesAgreement(dirs, patterns, action, enable_back, base_product, require_agreement) ⇒ Object
Ask user to confirm license agreement
270 271 272 273 274 275 276 277 |
# File 'src/modules/ProductLicense.rb', line 270 def AskLicensesAgreement(dirs, patterns, action, enable_back, base_product, require_agreement) # dialog caption caption = _("License Agreement") heading = nil AskLicensesAgreementWithHeading(dirs, patterns, action, enable_back, base_product, require_agreement, caption, heading) end |
#AskLicensesAgreementWithHeading(dirs, _patterns, action, enable_back, base_product, require_agreement, caption, heading) ⇒ Object
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 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'src/modules/ProductLicense.rb', line 282 def AskLicensesAgreementWithHeading(dirs, _patterns, action, enable_back, base_product, require_agreement, caption, heading) dirs = deep_copy(dirs) if dirs.nil? || dirs == [] Builtins.y2error("No directories: %1", dirs) # error message Report.Error("Internal Error: No license to show") return :auto end created_new_dialog = false # #459391 # If a progress is running open another dialog if Progress.IsRunning Builtins.y2milestone( "Some progress is running, opening new dialog for license..." ) Wizard.OpenNextBackDialog created_new_dialog = true end license_idents = [] licenses = [] counter = -1 contents = VBox( if heading VBox( VSpacing(0.5), Left(Heading(heading)), VSpacing(0.5) ) else Empty() end ) Builtins.foreach(dirs) do |dir| counter = Ops.add(counter, 1) Ops.set(licenses, counter, {}) @lic_lang = "" available_langs = [] license_ident = "" tmp_licenses = {} tmp_licenses_ref = arg_ref(tmp_licenses) available_langs_ref = arg_ref(available_langs) license_ident_ref = arg_ref(license_ident) InitLicenseData( nil, dir, tmp_licenses_ref, available_langs_ref, require_agreement, license_ident_ref, dir ) tmp_licenses = tmp_licenses_ref.value available_langs = available_langs_ref.value license_ident = license_ident_ref.value if !license_ident.nil? license_idents = Builtins.add(license_idents, license_ident) end license_term = ( tmp_licenses_ref = arg_ref(tmp_licenses) result = GetLicenseDialog( available_langs, @lic_lang, tmp_licenses_ref, dir, true ) tmp_licenses = tmp_licenses_ref.value result ) if license_term.nil? Builtins.y2error("Oops, license term is: %1", license_term) else contents = Builtins.add(contents, license_term) end # Display beta file as a popup if exists InstShowInfo.show_info_txt(@beta_file) if !@beta_file.nil? Ops.set(licenses, counter, tmp_licenses) end Wizard.SetContents( caption, contents, GetLicenseDialogHelp(), enable_back, true # always enable next, as popup is raised if not accepted (bnc#993530) ) Wizard.SetTitleIcon("yast-license") Wizard.SetFocusToNextButton tmp_licenses = {} ret = ( tmp_licenses_ref = arg_ref(tmp_licenses) result = HandleLicenseDialogRet( tmp_licenses_ref, base_product, action ) result ) Builtins.y2milestone("Dialog ret: %1", ret) # store already accepted license IDs Builtins.foreach(license_idents) do |license_ident| LicenseHasBeenAccepted(license_ident) end if ret == :accepted CleanUpLicense(@tmpdir) # bugzilla #303922 Wizard.CloseDialog if created_new_dialog CleanUp() ret end |
#CleanUp ⇒ Object
Generic cleanup
140 141 142 143 144 145 146 |
# File 'src/modules/ProductLicense.rb', line 140 def CleanUp # BNC #581933: All license IDs are cached while the module is in memory. # Removing them when leaving the license dialog. @license_ids = [] nil end |
#DisplayLicenseDialogWithTitle(languages, back, license_language, licenses, id, caption) ⇒ Object
FIXME: this is needed only by yast2-registration, fix it later and make this method private
Displays License with Help and ( ) Yes / ( ) No radio buttons
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
# File 'src/modules/ProductLicense.rb', line 961 def DisplayLicenseDialogWithTitle(languages, back, license_language, licenses, id, caption) languages = deep_copy(languages) contents = ( licenses_ref = arg_ref(licenses.value) result = GetLicenseDialog( languages, license_language, licenses_ref, id, false ) licenses.value = licenses_ref.value result ) Wizard.SetContents( caption, contents, GetLicenseDialogHelp(), back, # always allow next button, as if not accepted, it will raise popup (bnc#993530) true ) # set the initial license download URL update_license_location(license_language, licenses) Wizard.SetTitleIcon("yast-license") Wizard.SetFocusToNextButton nil end |
#GetLicenseDialogHelp ⇒ Object
Help text for asking license for product
712 713 714 715 716 717 718 719 |
# File 'src/modules/ProductLicense.rb', line 712 def GetLicenseDialogHelp # help text _( "<p>Read the license agreement carefully and select\n" \ "one of the available options. If you do not agree to the license agreement,\n" \ "the configuration will be aborted.</p>\n" ) end |
#HandleLicenseDialogRet(licenses, base_product, action) ⇒ Object
FIXME: this is needed only by yast2-registration, fix it later and make this method private
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 |
# File 'src/modules/ProductLicense.rb', line 573 def HandleLicenseDialogRet(licenses, base_product, action) ret = nil loop do ret = UI.UserInput log.info "User ret: #{ret}" if ret.is_a?(::String) && ret.start_with?("license_language_") licenses_ref = arg_ref(licenses.value) UpdateLicenseContent(licenses_ref, GetId(ret)) licenses.value = licenses_ref.value ret = :language # bugzilla #303828 # disabled next button unless yes/no is selected elsif ret.is_a?(::String) && ret.start_with?("eula_") Wizard.EnableNextButton if AllLicensesAcceptedOrDeclined() # Aborting the license dialog elsif ret == :abort # bnc#886662 if Stage.initial next unless Popup.ConfirmAbort(:painless) else # popup question next unless Popup.YesNo(_("Really abort the add-on product installation?")) end log.warn "Aborting..." break elsif ret == :next if AllLicensesAccepted() log.info "All licenses have been accepted." ret = :accepted break end # License declined # message is void in case not accepting license doesn't stop the installation if action == "continue" log.info "action in case of license refusal is continue, not asking user" ret = :accepted break end if base_product # TODO: refactor to use same widget as in inst_complex_welcome # NOTE: keep in sync with inst_compex_welcome client, for grabing its translation # mimic inst_complex_welcome behavior see bnc#993530 refuse_popup_text = Builtins.dgettext( "installation", "You must accept the license to install this product" ) Popup.Message(refuse_popup_text) next else # text changed due to bug #162499 # TRANSLATORS: text asking whether to refuse a license (Yes-No popup) refuse_popup_text = _("Refusing the license agreement cancels the add-on\n" \ "product installation. Really refuse the agreement?") next unless Popup.YesNo(refuse_popup_text) end log.info "License has been declined." case action when "abort" ret = :abort when "halt" # timed ok/cancel popup next unless Popup.TimedOKCancel(_("The system is shutting down..."), 10) ret = :halt else log.error "Unknown action #{action}" ret = :abort end break elsif ret == :back ret = :back break else log.error "Unhandled input: #{ret}" end end log.info "Returning #{ret}" ret end |
#initialize_default_values ⇒ Object
(Re)Initializes all internal caches
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 |
# File 'src/modules/ProductLicense.rb', line 52 def initialize_default_values # All licenses have their own unique ID @license_ids = [] # License files by their eula_ID # # **Structure:** # # $["ID":$[licenses]] @all_licenses = {} # filename printed in the license dialog @license_file_print = nil # license file is on installed system @license_on_installed_system = false # BNC #448598 # no-acceptance-needed file in license.tar.gz means the license # doesn't have to be accepted by user, just displayed @license_acceptance_needed = {} @tmpdir = nil @license_dir = nil @beta_file = nil @lic_lang = "" # FIXME: map <string, boolean> ... @beta_file_already_seen = {} end |
#main ⇒ Object
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 |
# File 'src/modules/ProductLicense.rb', line 16 def main Yast.import "Pkg" Yast.import "UI" Yast.import "Directory" Yast.import "InstShowInfo" Yast.import "Language" Yast.import "Popup" Yast.import "Report" Yast.import "Stage" Yast.import "Wizard" Yast.import "Mode" Yast.import "FileUtils" Yast.import "ProductFeatures" Yast.import "String" Yast.import "WorkflowManager" Yast.import "Progress" # IMPORTANT: maintainer of yast2-installation is responsible for this module textdomain "packager" @license_patterns = [ "license\\.html", "license\\.%1\\.html", "license\\.htm", "license\\.%1\\.htm", "license\\.txt", "license\\.%1\\.txt" ] # no more wildcard patterns here, UI can display only html and txt anyway initialize_default_values end |
#SetAcceptanceNeeded(id, new_value) ⇒ Object
Sets whether explicit acceptance of a license is needed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'src/modules/ProductLicense.rb', line 118 def SetAcceptanceNeeded(id, new_value) if new_value.nil? Builtins.y2error( "Undefined behavior (License ID %1), AcceptanceNeeded: %2", id, new_value ) return end @license_acceptance_needed[id] = new_value if new_value == true log.info "License agreement (ID #{id}) WILL be required" else log.info "License agreement (ID #{id}) will NOT be required" end nil end |
#ShowFullScreenLicenseInInstallation(replace_point_ID, src_id) ⇒ Object
Called from the first stage Welcome dialog by clicking on a button
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 |
# File 'src/modules/ProductLicense.rb', line 441 def ShowFullScreenLicenseInInstallation(replace_point_ID, src_id) replace_point_ID = deep_copy(replace_point_ID) @lic_lang = "" licenses = {} available_langs = [] license_ident = "" licenses_ref = arg_ref(licenses) available_langs_ref = arg_ref(available_langs) license_ident_ref = arg_ref(license_ident) InitLicenseData( nil, "", licenses_ref, available_langs_ref, true, license_ident_ref, Builtins.tostring(src_id) ) licenses = licenses_ref.value available_langs = available_langs_ref.value # Replaces the dialog content with Languages combo-box # and the current license text (richtext) UI.ReplaceWidget( Id(replace_point_ID), ( licenses_ref = arg_ref(licenses) result = GetLicenseDialogTerm( available_langs, @lic_lang, licenses_ref, Builtins.tostring(src_id) ) licenses = licenses_ref.value result ) ) ret = nil loop do ret = UI.UserInput if Ops.is_string?(ret) && Builtins.regexpmatch( Builtins.tostring(ret), "^license_language_[[:digit:]]+" ) licenses_ref = arg_ref(licenses) UpdateLicenseContent(licenses_ref, GetId(Builtins.tostring(ret))) licenses = licenses_ref.value else break end end CleanUp() true end |
#ShowLicenseInInstallation(replace_point_ID, src_id) ⇒ Object
Used in the first-stage Welcome dialog
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 |
# File 'src/modules/ProductLicense.rb', line 504 def ShowLicenseInInstallation(replace_point_ID, src_id) replace_point_ID = deep_copy(replace_point_ID) @lic_lang = "" licenses = {} available_langs = [] license_ident = "" licenses_ref = arg_ref(licenses) available_langs_ref = arg_ref(available_langs) license_ident_ref = arg_ref(license_ident) InitLicenseData( nil, "", licenses_ref, available_langs_ref, true, license_ident_ref, Builtins.tostring(src_id) ) licenses = licenses_ref.value licenses_ref = arg_ref(licenses) rt = GetLicenseContent( @lic_lang, licenses_ref, Builtins.tostring(src_id) ) UI.ReplaceWidget(Id(replace_point_ID), rt) display_beta(src_id) if @beta_file && !beta_seen?(src_id) CleanUp() true end |