Class: Yast::SourceDialogsClass
- Inherits:
-
Module
- Object
- Module
- Yast::SourceDialogsClass
- Extended by:
- I18n
- Includes:
- Logger
- Defined in:
- ../../src/modules/SourceDialogs.rb
Constant Summary
- WIDGET_LABELS =
widget ID => translatable label (needs to be translated by _())
{ # radio button :slp => N_("&Scan Using SLP..."), # radio button :comm_repos => N_("Commun&ity Repositories"), # radio button :sccrepos => N_("&Extensions and Modules from Registration Server..."), # radio button :specify_url => N_("Specify &URL..."), # radio button :ftp => N_("&FTP..."), # radio button :http => N_("&HTTP..."), # radio button :https => N_("HTT&PS..."), # radio button :samba => N_("&SMB/CIFS"), # radio button :nfs => N_("&NFS..."), # radio button :cd => N_("&CD..."), # radio button :dvd => N_("&DVD..."), # radio button :hd => N_("&Hard Disk..."), # radio button :usb => N_("&USB Mass Storage (USB Stick, Disk)..."), # radio button :local_dir => N_("&Local Directory..."), # radio button :local_iso => N_("&Local ISO Image..."), # check box :download_metadata => N_("&Download repository description files"), }
Instance Attribute Summary (collapse)
-
- (Object) addon_enabled
readonly
the status of the global checkbox.
-
- (Object) display_addon_checkbox
display a global enable/disable checkbox in URL type dialog.
Instance Method Summary (collapse)
- - (Object) addon_checkbox_term
- - (Object) addon_spacing_term
-
- (Object) CDInit(key)
Init function of a widget.
-
- (Object) CDStore(key, event)
Store function of a widget.
-
- (Object) CDWidget
Get widget description map.
-
- (Boolean) confirm_abort?
Returns boolean whether user confirmed to abort the configuration.
-
- (Boolean) CRURLDefined
Returns whether Community Repositories are defined in the control file.
- - (Object) DetectDisk(usb_only)
- - (Object) DetectHardDisk
- - (Object) DetectPartitions(disk_id)
- - (Object) DetectUSBDisk
-
- (Object) DirHandle(key, event)
Handle function of a widget.
-
- (Object) DirInit(key)
Init function of a widget.
-
- (Object) DirStore(key, event)
Store function of a widget.
- - (Object) DirValidate(key, event)
-
- (Object) DirWidget
Get widget description map.
-
- (Object) DiskInit(key)
Init function of a widget.
- - (Object) DiskSelectionList(disks, selected)
-
- (Object) DiskStore(key, event)
Store function of a widget.
-
- (Object) DiskWidget
Get widget description map.
-
- (Symbol) EditDialog
Sample implementation of URL selection dialog.
-
- (Symbol) EditDialogProtocol(proto)
Sample implementation of URL selection dialog.
-
- (Symbol) EditDialogProtocolService(proto)
Sample implementation of URL selection dialog.
- - (Object) EditDisplay
- - (Object) EditDisplayInt(repository)
- - (Object) EditDisplayService
-
- (String) EditPopup(url)
URL editation popup.
-
- (String) EditPopupNoHTTPS(url)
URL editation popup without the HTTPS option.
-
- (String) EditPopupService(url)
URL editation popup.
-
- (String) EditPopupType(url, plaindir_type)
URL editation popup, allows setting plaindir type.
- - (Object) GetDeviceID(devices)
- - (Object) GetDownloadOption
-
- (String) GetRawURL
Return the configured URL in the dialog, do not do any conversion (return the internal value).
-
- (String) GetRepoName
Return RepoName after the run of the dialog.
-
- (String) GetURL
Return URL after the run of the dialog.
-
- (Object) InitDiskWidget(disks)
common code for USBInit() and DiskInit().
- - (Object) InitFocusServerInit(server_type)
-
- (Object) IsAnyNetworkAvailable
Checks whether some network is available in the current moment, see the bug #170147 for more information.
-
- (Boolean) IsISOURL(url)
Check if URL is an ISO URL.
-
- (Object) IsoHandle(key, event)
Handle function of a widget.
-
- (Object) IsoInit(key)
Init function of a widget.
-
- (Object) IsoStore(key, event)
Store function of a widget.
- - (Object) IsoValidate(key, event)
-
- (Object) IsoWidget
Get widget description map.
- - (Object) IsPlainDir
- - (Object) main
-
- (Object) NFSHandle(key, event)
Handle function of a widget.
-
- (Object) NFSInit(key)
Init function of a widget.
-
- (Object) NFSStore(key, event)
Store function of a widget.
- - (Object) NFSStoreComplete
- - (Object) NFSStoreParts
-
- (Object) NFSWidget
Get widget description map.
-
- (String) NormalizeHost(host)
Remove leading and trailing (and inner) spaces from the host name.
-
- (Boolean) PathIsISO(url)
check if given path points to ISO file.
-
- (Object) PlainURLInit(key)
Init function of a widget.
-
- (Object) PlainURLStore(key, event)
Store function of a widget.
- - (Object) PlainURLValidate(key, event)
-
- (Object) PlainURLWidget
Get widget description map.
-
- (Object) PopupButtons
Return an HBox with ok and cancel buttons for use by other dialogs.
-
- (Yast::Term) PopupContents(proto, repository)
Get contents of a popup for specified protocol.
-
- (String) PostprocessISOURL(url)
Postprocess URL of an ISO image.
-
- (String) PreprocessISOURL(url)
Preprocess the ISO URL to be used in the dialogs.
- - (Object) RefreshTypeWidgets
-
- (Object) RepoNameInit(key)
Init function of a widget.
-
- (Object) RepoNameStore(key, event)
Store function of a widget.
- - (Object) RepoNameValidate(key, event)
-
- (Object) RepoNameWidget
Get widget description map.
- - (Object) scc_repos_widget
-
- (Symbol) SelectHandle(key, event)
Handles Ui events in New repository type selection dialog.
- - (Object) SelectInit(key)
- - (Object) SelectRadioWidget
- - (Object) SelectRadioWidgetDL
-
- (Object) SelectRadioWidgetOpt(download_widget)
FIXME: two almost same definitions in the same function smell bad.
- - (Object) SelectStore(key, event)
- - (Object) SelectStoreDl(key, event)
- - (Object) SelectValidate(key, event)
- - (Object) SelectWidget
- - (Object) SelectWidgetDL
- - (Object) SelectWidgetHelp
- - (Object) SelectWidgetHelpDl
-
- (Object) ServerHandle(key, event)
Handle function of a widget.
- - (Object) ServerInit(key)
- - (Object) ServerStore(key, event)
- - (Object) ServerStoreComplete
- - (Object) ServerStoreParts
- - (Object) ServerValidate(key, event)
-
- (Object) ServerWidget
Get widget description map.
- - (Object) ServiceNameWidget
- - (Object) SetDownloadOption(download)
- - (Object) SetFileSystems(selected_fs)
-
- (Object) SetRepoName(repo_name)
Set the RepoName to work with.
-
- (Object) SetURL(url)
Set the URL to work with.
-
- (Object) SetURLType(url, plaindir_type)
Set the URL to work with, set the plaindir flag (type of the repository).
-
- (String) Slashed(urlpart)
Add a slash to the part of url, if it is not already present.
-
- (Symbol) TypeDialog
Sample implementation of URL type selection dialog.
-
- (Symbol) TypeDialogDownloadOpt
Sample implementation of URL type selection dialog.
-
- (String) TypePopup
URL editation popup with the HTTPS option.
-
- (String) URLScheme(url)
Get scheme of a URL, also for ISO URL get scheme of the access protocol.
-
- (Object) USBInit(key)
Init function of a widget.
-
- (Object) USBStore(key, event)
Store function of a widget.
-
- (Object) USBWidget
Get widget description map.
-
- (Object) Widgets
Get individual widgets.
Instance Attribute Details
- (Object) addon_enabled (readonly)
the status of the global checkbox
26 27 28 |
# File '../../src/modules/SourceDialogs.rb', line 26 def addon_enabled @addon_enabled end |
- (Object) display_addon_checkbox
display a global enable/disable checkbox in URL type dialog
24 25 26 |
# File '../../src/modules/SourceDialogs.rb', line 24 def display_addon_checkbox @display_addon_checkbox end |
Instance Method Details
- (Object) addon_checkbox_term
1954 1955 1956 1957 1958 1959 1960 1961 1962 |
# File '../../src/modules/SourceDialogs.rb', line 1954 def addon_checkbox_term @display_addon_checkbox ? VBox( Left(CheckBox(Id(:add_addon), Opt(:notify), _("I would like to install an additional Add On Product"), false)), VSpacing(1), ) : Empty() end |
- (Object) addon_spacing_term
1964 1965 1966 |
# File '../../src/modules/SourceDialogs.rb', line 1964 def addon_spacing_term @display_addon_checkbox ? HSpacing(3) : Empty() end |
- (Object) CDInit(key)
Init function of a widget
765 766 767 768 769 770 771 772 773 774 775 |
# File '../../src/modules/SourceDialogs.rb', line 765 def CDInit(key) parsed = URL.Parse(@_url) scheme = Ops.get_string(parsed, "scheme", "") if scheme == "dvd" UI.ChangeWidget(Id(:dvd), :Value, true) else UI.ChangeWidget(Id(:cd), :Value, true) end nil end |
- (Object) CDStore(key, event)
Store function of a widget
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File '../../src/modules/SourceDialogs.rb', line 780 def CDStore(key, event) event = deep_copy(event) device = Convert.to_symbol(UI.QueryWidget(Id(:device), :CurrentButton)) parsed = URL.Parse(@_url) scheme = Builtins.tolower(Ops.get_string(parsed, "scheme", "")) # preserve other URL options, e.g. ?devices=/dev/sr0 # change the URL only when necessary if device == :cd && scheme != "cd" @_url = "cd:///" elsif device == :dvd && scheme != "dvd" @_url = "dvd:///" end nil end |
- (Object) CDWidget
Get widget description map
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
# File '../../src/modules/SourceDialogs.rb', line 799 def CDWidget { "widget" => :custom, "custom_widget" => RadioButtonGroup( Id(:device), VBox( # radio button Left(RadioButton(Id(:cd), _("&CD-ROM"))), # radio button Left(RadioButton(Id(:dvd), _("&DVD-ROM"))) ) ), "init" => fun_ref(method(:CDInit), "void (string)"), "store" => fun_ref(method(:CDStore), "void (string, map)"), "help" => _( "<p><big><b>CD or DVD Media</b></big><br>\nSet <b>CD-ROM</b> or <b>DVD-ROM</b> to specify the type of media.</p>" ) } end |
- (Boolean) confirm_abort?
Returns boolean whether user confirmed to abort the configuration
2624 2625 2626 |
# File '../../src/modules/SourceDialogs.rb', line 2624 def confirm_abort? (Stage.initial ? Popup.ConfirmAbort(:painless) : Popup.ReallyAbort(SourceManager.Modified())) end |
- (Boolean) CRURLDefined
Returns whether Community Repositories are defined in the control file.
1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 |
# File '../../src/modules/SourceDialogs.rb', line 1936 def CRURLDefined link = ProductFeatures.GetStringFeature( "software", "external_sources_link" ) Builtins.y2debug("software/external_sources_link -> '%1'", link) if link == nil || link == "" Builtins.y2milestone( "No software/external_sources_link, community repos will be disabled" ) return false else return true end end |
- (Object) DetectDisk(usb_only)
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 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 |
# File '../../src/modules/SourceDialogs.rb', line 1071 def DetectDisk(usb_only) Builtins.y2milestone("Detecting %1USB disks", usb_only ? "" : "non-") disks = Convert.convert( SCR.Read(path(".probe.disk")), :from => "any", :to => "list <map>" ) Builtins.y2debug("Detected disks: %1", disks) disks = Builtins.filter(disks) do |disk| Ops.get_string(disk, "driver", "") == "usb-storage" && usb_only || Ops.get_string(disk, "driver", "") != "usb-storage" && !usb_only end Builtins.y2milestone("Found disks: %1", disks) ret = [] Builtins.foreach(disks) do |disk| dev_id = GetDeviceID(Ops.get_list(disk, "dev_names", [])) ret = Builtins.add( ret, { "model" => Ops.get_string(disk, "model", ""), # compute the size (number of sectors * size of sector) "size" => Ops.multiply( Ops.get_integer(disk, ["resource", "size", 0, "x"], 0), Ops.get_integer(disk, ["resource", "size", 0, "y"], 0) ), "dev" => Ops.get_string(disk, "dev_name", ""), "dev_by_id" => dev_id, "partitions" => DetectPartitions(dev_id) } ) end Builtins.y2milestone("Disk configuration: %1", ret) deep_copy(ret) end |
- (Object) DetectHardDisk
1118 1119 1120 |
# File '../../src/modules/SourceDialogs.rb', line 1118 def DetectHardDisk DetectDisk(false) end |
- (Object) DetectPartitions(disk_id)
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
# File '../../src/modules/SourceDialogs.rb', line 1037 def DetectPartitions(disk_id) command = Builtins.sformat("ls %1-part*", disk_id) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), command)) if Ops.get_integer(out, "exit", -1) != 0 Builtins.y2error("Command %1 failed", command) return [] end ret = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ret_size = Builtins.size(ret) # remove empty string at the end if Ops.greater_than(ret_size, 0) && Ops.get(ret, Ops.subtract(ret_size, 1), "dummy") == "" ret = Builtins.remove(ret, Ops.subtract(ret_size, 1)) end deep_copy(ret) end |
- (Object) DetectUSBDisk
1114 1115 1116 |
# File '../../src/modules/SourceDialogs.rb', line 1114 def DetectUSBDisk DetectDisk(true) end |
- (Object) DirHandle(key, event)
Handle function of a widget
885 886 887 888 889 890 891 892 893 894 |
# File '../../src/modules/SourceDialogs.rb', line 885 def DirHandle(key, event) event = deep_copy(event) dir = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) # dialog caption result = UI.AskForExistingDirectory(dir, _("Local Directory")) UI.ChangeWidget(Id(:dir), :Value, result) if result != nil nil end |
- (Object) DirInit(key)
Init function of a widget
823 824 825 826 827 828 829 830 831 832 |
# File '../../src/modules/SourceDialogs.rb', line 823 def DirInit(key) parsed = URL.Parse(@_url) UI.ChangeWidget(Id(:dir), :Value, Ops.get_string(parsed, "path", "")) UI.SetFocus(:dir) # is it a plain directory? UI.ChangeWidget(Id(:ch_plain), :Value, @_plaindir) nil end |
- (Object) DirStore(key, event)
Store function of a widget
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
# File '../../src/modules/SourceDialogs.rb', line 849 def DirStore(key, event) event = deep_copy(event) parsed = { "scheme" => "dir", "path" => Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) } if Convert.to_boolean(UI.QueryWidget(Id(:ch_plain), :Value)) @_plaindir = true end @_url = URL.Build(parsed) nil end |
- (Object) DirValidate(key, event)
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 |
# File '../../src/modules/SourceDialogs.rb', line 910 def DirValidate(key, event) event = deep_copy(event) s = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) if s == nil || s == "" # error popup Popup.Error(Message.RequiredItem) UI.SetFocus(Id(:dir)) return false end stat = Convert.to_map(SCR.Read(path(".target.stat"), s)) Builtins.y2milestone("stat %1: %2", s, stat) if !Ops.get_boolean(stat, "isdir", false) # error popup - the entered path is not a directory Report.Error( _( "The entered path is not a directory\nor the directory does not exist.\n" ) ) UI.SetFocus(Id(:dir)) return false end true end |
- (Object) DirWidget
Get widget description map
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File '../../src/modules/SourceDialogs.rb', line 996 def DirWidget { "widget" => :custom, "custom_widget" => VBox( HBox( # text entry InputField(Id(:dir), Opt(:hstretch), _("&Path to Directory")), VBox( Label(""), # push button PushButton(Id(:browse), Label.BrowseButton) ) ), # checkbox label Left(CheckBox(Id(:ch_plain), _("&Plain RPM Directory"))) ), "init" => fun_ref(method(:DirInit), "void (string)"), "store" => fun_ref(method(:DirStore), "void (string, map)"), "handle" => fun_ref( method(:DirHandle), "symbol (string, map)" ), "handle_events" => [:browse], "validate_type" => :function, "validate_function" => fun_ref( method(:DirValidate), "boolean (string, map)" ), "help" => Ops.add( _( "<p><big><b>Local Directory</b></big><br>\n" + "Use <b>Path to Directory</b> to specify the path to the\n" + "directory. If the directory contains only RPM packages without\n" + "any metadata (i.e. there is no product information), then check option\n" + "<b>Plain RPM Directory</b>.</p>\n" ), @multi_cd_help ) } end |
- (Object) DiskInit(key)
Init function of a widget
1292 1293 1294 1295 1296 1297 1298 |
# File '../../src/modules/SourceDialogs.rb', line 1292 def DiskInit(key) # refresh the cache disks = DetectHardDisk() InitDiskWidget(disks) nil end |
- (Object) DiskSelectionList(disks, selected)
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
# File '../../src/modules/SourceDialogs.rb', line 1122 def DiskSelectionList(disks, selected) disks = deep_copy(disks) ret = [] found = false Builtins.foreach(disks) do |disk| label = Ops.get_string(disk, "model", "") # add size if it's known and there is just one partition # TODO detect size of each partition sz = Ops.get_integer(disk, "size", 0) if Ops.greater_than(sz, 0) && Builtins.size(Ops.get_list(disk, "partitions", [])) == 1 label = Ops.add(Ops.add(label, " - "), String.FormatSize(sz)) end dev = Ops.get_string(disk, "dev", "") Builtins.foreach(Ops.get_list(disk, "partitions", [])) do |part| partnum = Builtins.regexpsub(part, ".*-part([0-9]*)$", "\\1") disk_label = Ops.add(label, Builtins.sformat(" (%1%2)", dev, partnum)) found = found || part == selected ret = Builtins.add(ret, Item(Id(part), disk_label, part == selected)) end end if !found && Builtins.regexpmatch(selected, "^/dev/disk/by-id/usb-") Builtins.y2milestone( "USB disk %1 is not currently attached, adding the raw device to the list", selected ) # remove the /dev prefix dev_name = Builtins.regexpsub( selected, "^/dev/disk/by-id/usb-(.*)", "\\1" ) ret = Builtins.add(ret, Item(Id(selected), dev_name, true)) end deep_copy(ret) end |
- (Object) DiskStore(key, event)
Store function of a widget
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 |
# File '../../src/modules/SourceDialogs.rb', line 1303 def DiskStore(key, event) event = deep_copy(event) # build URL like this: usb:///openSUSE?device=/dev/sdb8&filesystem=auto query = Builtins.sformat( "device=%1&filesystem=%2", Convert.to_string(UI.QueryWidget(Id(:disk), :Value)), Convert.to_string(UI.QueryWidget(Id(:fs), :Value)) ) dir = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) @_plaindir = Convert.to_boolean(UI.QueryWidget(Id(:ch_plain), :Value)) parsed = { "scheme" => "hd", "path" => dir, "query" => query } @_url = URL.Build(parsed) Builtins.y2milestone("New Disk url: %1", URL.HidePassword(@_url)) nil end |
- (Object) DiskWidget
Get widget description map
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 |
# File '../../src/modules/SourceDialogs.rb', line 1327 def DiskWidget { "widget" => :custom, "custom_widget" => VBox( # combobox title ComboBox(Id(:disk), Opt(:hstretch), _("&Disk Device")), ComboBox(Id(:fs), Opt(:editable), _("&File System")), InputField(Id(:dir), _("Dire&ctory")), Left(CheckBox(Id(:ch_plain), _("&Plain RPM Directory"))) ), "init" => fun_ref(method(:DiskInit), "void (string)"), "store" => fun_ref(method(:DiskStore), "void (string, map)"), "help" => _( "<p><big><b>Disk</b></big><br>\n" + "Select the disk on which the repository is located.\n" + "Use <b>Path to Directory</b> to specify the directory of the repository.\n" + "If the path is omitted, the system will use the root directory of the disk.\n" + "If the directory contains only RPM packages without\n" + "any metadata (i.e. there is no product information), then check option\n" + "<b>Plain RPM Directory</b>.</p>\n" ) + # 'auto' is a value in the combo box widget, do not translate it! _( "<p>The file system used on the device will be detected automatically\n" + "if you select file system 'auto'. If the detection fails or you\n" + "want to use a certain file system, select it from the list.</p>\n" ) } end |
- (Symbol) EditDialog
Sample implementation of URL selection dialog
2550 2551 2552 2553 2554 |
# File '../../src/modules/SourceDialogs.rb', line 2550 def EditDialog proto = URLScheme(@_url) EditDialogProtocol(proto) end |
- (Symbol) EditDialogProtocol(proto)
Sample implementation of URL selection dialog
2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 |
# File '../../src/modules/SourceDialogs.rb', line 2509 def EditDialogProtocol(proto) Builtins.y2milestone("Displaying dialog for protocol %1", proto) caption = Ops.get(@_caption, proto, "") CWM.ShowAndRun( { "widget_names" => ["repo_name", proto], "widget_descr" => Widgets(), "contents" => HVCenter( MinWidth(65, VBox("repo_name", proto)) ), "caption" => caption, "back_button" => Label.BackButton, "next_button" => Label.NextButton, "fallback_functions" => @default_cwm_fallback_functions, } ) end |
- (Symbol) EditDialogProtocolService(proto)
Sample implementation of URL selection dialog
2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 |
# File '../../src/modules/SourceDialogs.rb', line 2530 def EditDialogProtocolService(proto) Builtins.y2milestone("Displaying service dialog for protocol %1", proto) caption = Ops.get(@_caption, proto, "") CWM.ShowAndRun( { "widget_names" => ["service_name", proto], "widget_descr" => Widgets(), "contents" => HVCenter( MinWidth(65, VBox("service_name", proto)) ), "caption" => caption, "back_button" => Label.BackButton, "next_button" => Label.NextButton, "fallback_functions" => @default_cwm_fallback_functions, } ) end |
- (Object) EditDisplay
2462 2463 2464 |
# File '../../src/modules/SourceDialogs.rb', line 2462 def EditDisplay EditDisplayInt(true) end |
- (Object) EditDisplayInt(repository)
2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 |
# File '../../src/modules/SourceDialogs.rb', line 2435 def EditDisplayInt(repository) proto = URLScheme(@_url) Builtins.y2milestone( "Displaying %1 popup for protocol %2", repository ? "repository" : "service", proto ) w = CWM.CreateWidgets( [repository ? "repo_name" : "service_name", proto], Widgets() ) Builtins.y2milestone("w: %1", w) contents = PopupContents(proto, repository) contents = CWM.PrepareDialog(contents, w) UI.OpenDialog(contents) ret = CWM.Run(w, {}) Builtins.y2milestone("Ret: %1", ret) UI.CloseDialog if ret == :ok return GetURL() else return "" end end |
- (Object) EditDisplayService
2466 2467 2468 |
# File '../../src/modules/SourceDialogs.rb', line 2466 def EditDisplayService EditDisplayInt(false) end |
- (String) EditPopup(url)
URL editation popup
2473 2474 2475 2476 2477 |
# File '../../src/modules/SourceDialogs.rb', line 2473 def EditPopup(url) SetURL(url) EditDisplay() end |
- (String) EditPopupNoHTTPS(url)
URL editation popup without the HTTPS option
2500 2501 2502 2503 2504 2505 |
# File '../../src/modules/SourceDialogs.rb', line 2500 def EditPopupNoHTTPS(url) @_allow_https = false ret = EditPopup(url) @_allow_https = true ret end |
- (String) EditPopupService(url)
URL editation popup
2482 2483 2484 2485 2486 |
# File '../../src/modules/SourceDialogs.rb', line 2482 def EditPopupService(url) SetURL(url) EditDisplayService() end |
- (String) EditPopupType(url, plaindir_type)
URL editation popup, allows setting plaindir type
2492 2493 2494 2495 2496 |
# File '../../src/modules/SourceDialogs.rb', line 2492 def EditPopupType(url, plaindir_type) SetURLType(url, plaindir_type) EditDisplay() end |
- (Object) GetDeviceID(devices)
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 |
# File '../../src/modules/SourceDialogs.rb', line 1059 def GetDeviceID(devices) devices = deep_copy(devices) ret = "" Builtins.foreach(devices) do |dev| ret = dev if Builtins.regexpmatch(dev, "^/dev/disk/by-id/") end ret end |
- (Object) GetDownloadOption
2337 2338 2339 |
# File '../../src/modules/SourceDialogs.rb', line 2337 def GetDownloadOption @_download_metadata end |
- (String) GetRawURL
Return the configured URL in the dialog, do not do any conversion (return the internal value)
294 295 296 |
# File '../../src/modules/SourceDialogs.rb', line 294 def GetRawURL @_url end |
- (String) GetRepoName
Return RepoName after the run of the dialog
312 313 314 |
# File '../../src/modules/SourceDialogs.rb', line 312 def GetRepoName @_repo_name end |
- (String) GetURL
Return URL after the run of the dialog
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File '../../src/modules/SourceDialogs.rb', line 275 def GetURL parsed = URL.Parse(@_url) # usb scheme is not valid, it's used only internally # convert it for external clients if Ops.get_string(parsed, "scheme", "") == "usb" Ops.set(parsed, "scheme", "hd") Ops.set(parsed, "path", "/") if Ops.get_string(parsed, "path", "") == "" ret_url = URL.Build(parsed) return ret_url else return @_url end end |
- (Object) InitDiskWidget(disks)
common code for USBInit() and DiskInit()
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
# File '../../src/modules/SourceDialogs.rb', line 1191 def InitDiskWidget(disks) disks = deep_copy(disks) parsed = URL.Parse(@_url) query = URL.MakeMapFromParams(Ops.get_string(parsed, "query", "")) UI.ChangeWidget( Id(:disk), :Items, DiskSelectionList(disks, Ops.get(query, "device", "")) ) SetFileSystems(Ops.get(query, "filesystem", "auto")) UI.ChangeWidget(Id(:dir), :Value, Ops.get_string(parsed, "path", "")) # is it a plain directory? UI.ChangeWidget(Id(:ch_plain), :Value, @_plaindir) UI.SetFocus(:disk) nil end |
- (Object) InitFocusServerInit(server_type)
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
# File '../../src/modules/SourceDialogs.rb', line 1393 def InitFocusServerInit(server_type) case server_type when :ftp UI.SetFocus(:server) when :http UI.SetFocus(:server) when :https UI.SetFocus(:server) when :samba UI.SetFocus(:server) end nil end |
- (Object) IsAnyNetworkAvailable
Checks whether some network is available in the current moment, see the bug #170147 for more information.
1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 |
# File '../../src/modules/SourceDialogs.rb', line 1906 def IsAnyNetworkAvailable ret = false command = "TERM=dumb /sbin/ip -o address show | grep inet | grep -v scope.host" Builtins.y2milestone("Running %1", command) cmd_run = Convert.to_map( SCR.Execute(path(".target.bash_output"), command) ) Builtins.y2milestone("Command returned: %1", cmd_run) # command failed if Ops.get_integer(cmd_run, "exit", -1) != 0 # some errors were there, we don't know the status, rather return that it's available # `grep` also returns non zero exit code when there is nothing to do... if Ops.get_string(cmd_run, "stdout", "") != "" Builtins.y2error("Checking the network failed") ret = true end # some devices are listed elsif Ops.get_string(cmd_run, "stdout", "") != nil && Ops.get_string(cmd_run, "stdout", "") != "" ret = true end ret end |
- (Boolean) IsISOURL(url)
Check if URL is an ISO URL
334 335 336 337 338 339 |
# File '../../src/modules/SourceDialogs.rb', line 334 def IsISOURL(url) ret = Builtins.substring(url, 0, 5) == "iso:/" && Builtins.issubstring(url, "&url=") Builtins.y2milestone("URL %1 is ISO: %2", URL.HidePassword(url), ret) ret end |
- (Object) IsoHandle(key, event)
Handle function of a widget
900 901 902 903 904 905 906 907 908 909 |
# File '../../src/modules/SourceDialogs.rb', line 900 def IsoHandle(key, event) event = deep_copy(event) dir = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) # dialog caption result = UI.AskForExistingFile(dir, "*", _("ISO Image File")) UI.ChangeWidget(Id(:dir), :Value, result) if result != nil nil end |
- (Object) IsoInit(key)
Init function of a widget
836 837 838 839 840 841 842 843 844 |
# File '../../src/modules/SourceDialogs.rb', line 836 def IsoInit(key) @_url = PreprocessISOURL(@_url) parsed = URL.Parse(@_url) UI.ChangeWidget(Id(:dir), :Value, Ops.get_string(parsed, "path", "")) UI.SetFocus(:dir) nil end |
- (Object) IsoStore(key, event)
Store function of a widget
868 869 870 871 872 873 874 875 876 877 878 879 |
# File '../../src/modules/SourceDialogs.rb', line 868 def IsoStore(key, event) event = deep_copy(event) parsed = { "scheme" => "file", "path" => Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) } @_url = URL.Build(parsed) @_url = PostprocessISOURL(@_url) nil end |
- (Object) IsoValidate(key, event)
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 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/SourceDialogs.rb', line 940 def IsoValidate(key, event) event = deep_copy(event) s = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) if s == nil || s == "" # error popup Popup.Error(Message.RequiredItem) UI.SetFocus(Id(:dir)) return false end stat = Convert.to_map(SCR.Read(path(".target.stat"), s)) Builtins.y2milestone("stat %1: %2", s, stat) if !Ops.get_boolean(stat, "isreg", false) # error popup - the entered path is not a regular file Report.Error( _("The entered path is not a file\nor the file does not exist.\n") ) UI.SetFocus(Id(:dir)) return false end file = "/usr/bin/file" # try to detect ISO image by file if it's present if Ops.greater_than(SCR.Read(path(".target.size"), file), 0) # Use also -k as new images contain at first DOS boot sector for UEFI # then iso magic block command = Builtins.sformat("%1 -kb -- '%2'", file, String.Quote(s)) out = SCR.Execute(path(".target.bash_output"), command) stdout = out["stdout"] || "" if stdout.include? "ISO 9660 CD-ROM filesystem" Builtins.y2milestone("ISO 9660 image detected") else # continue/cancel popup, %1 is a file name return Popup.ContinueCancel( Builtins.sformat( _( "File '%1'\n" + "does not seem to be an ISO image.\n" + "Use it anyway?\n" ), s ) ) end end true end |
- (Object) IsoWidget
Get widget description map
1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 |
# File '../../src/modules/SourceDialogs.rb', line 1359 def IsoWidget { "widget" => :custom, "custom_widget" => VBox( HBox( # text entry InputField(Id(:dir), Opt(:hstretch), _("&Path to ISO Image")), VBox( Label(""), # push button PushButton(Id(:browse), Label.BrowseButton) ) ) ), "init" => fun_ref(method(:IsoInit), "void (string)"), "store" => fun_ref(method(:IsoStore), "void (string, map)"), "handle" => fun_ref( method(:IsoHandle), "symbol (string, map)" ), "handle_events" => [:browse], "validate_type" => :function, "validate_function" => fun_ref( method(:IsoValidate), "boolean (string, map)" ), "help" => _( "<p><big><b>Local ISO Image</b></big><br>\n" + "Use <b>Path to ISO Image</b> to specify the path to the\n" + "ISO image file.</p>" ) } end |
- (Object) IsPlainDir
298 299 300 |
# File '../../src/modules/SourceDialogs.rb', line 298 def IsPlainDir @_plaindir end |
- (Object) main
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 139 140 141 142 143 144 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 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 |
# File '../../src/modules/SourceDialogs.rb', line 64 def main Yast.import "Pkg" Yast.import "UI" textdomain "packager" Yast.import "Label" Yast.import "URL" Yast.import "URLRecode" Yast.import "Popup" Yast.import "CWM" Yast.import "SourceManager" Yast.import "Message" Yast.import "Report" Yast.import "NetworkPopup" Yast.import "String" Yast.import "Hostname" Yast.import "IP" Yast.import "ProductControl" Yast.import "ProductFeatures" Yast.import "Stage" # common functions / data # URL to work with @_url = "" # The repo at _url is plaindir @_plaindir = false # Repo name to work with @_repo_name = "" # value of the "download" check box @_download_metadata = true # Allow HTTPS for next repository dialog? @_allow_https = true # display a check box in type selection dialog in the next run @display_addon_checkbox = false # CD/DVD device name to use (e.g. /dev/sr1) in case of multiple # devices in the system. Empty string means use the default. @cd_device_name = "" # Help text suffix for some types of the media @iso_help = _( "<p>If the location is a file holding an ISO image\nof the media, set <b>ISO Image</b>.</p>" ) # Help text suffix for some types of the media @multi_cd_help = _( "<p>If the repository is on multiple media,\nset the location of the first media of the set.</p>\n" ) # Belongs to a constant, but can't be there because of `fun_ref` @default_cwm_fallback_functions = { :abort => fun_ref(method(:confirm_abort?), "boolean ()") } # NFS editation widget @nfs_details_content = VBox( HBox( # text entry InputField(Id(:server), Opt(:hstretch), _("&Server Name")), VBox(Label(""), PushButton(Id(:nfs_browse), Label.BrowseButton)) ), HBox( # text entry InputField( Id(:dir), Opt(:hstretch), _("&Path to Directory or ISO Image") ), VBox( Label(""), PushButton(Id(:nfs_exports_browse), Label.BrowseButton) ) ), # checkbox label Left(CheckBox(Id(:ch_iso), _("&ISO Image"))), # checkbox label Left(CheckBox(Id(:ch_nfs4), _("N&FS v4 Protocol"))), VSpacing(0.4), Left( ComboBox( Id(:mount_options), Opt(:editable), _("Mount Options"), [ # TRANSLATORS: "(default)" - is a combobox value and means default libzypp # NFS mount option (users can change it to anything else, the field is editable) Item(Id(:default), _("(default)"), true), "ro,nolock,soft,timeo=300", "ro,nolock,soft,timeo=300,sec=krb5p" ] ) ) ) @nfs_complete_content = InputField( Id(:complete_url), Opt(:hstretch), _("URL of the Repository") ) # dialog contents for different views @details_content = VBox( HBox( HSpacing(0.5), # frame Frame(_("P&rotocol"), ReplacePoint(Id(:rb_type_rp), Empty())), HSpacing(0.5) ), ReplacePoint(Id(:server_rp), Empty()) ) # input field label @complete_content = InputField( Id(:complete_url), Opt(:hstretch), _("&URL of the Repository") ) # use selected editing URL part, remember the value in case the URL is wrong # and the dialog needs to displayed again @editing_parts = false # general data # Individual widgets @_widgets = {} # Captions for individual protocols @_caption = { # label / dialog caption "url" => _("Repository URL"), # label / dialog caption "nfs" => _("NFS Server"), # label / dialog caption "cd" => _("CD or DVD Media"), # label / dialog caption "dvd" => _("CD or DVD Media"), # label / dialog caption "hd" => _("Hard Disk"), # label / dialog caption "usb" => _("USB Stick or Disk"), # label / dialog caption "dir" => _("Local Directory"), # label / dialog caption "file" => _("Local ISO Image"), # label / dialog caption "http" => _("Server and Directory"), # label / dialog caption "https" => _("Server and Directory"), # label / dialog caption "ftp" => _("Server and Directory"), # label / dialog caption "smb" => _("Server and Directory"), # label / dialog caption "cifs" => _("Server and Directory") } end |
- (Object) NFSHandle(key, event)
Handle function of a widget
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 |
# File '../../src/modules/SourceDialogs.rb', line 676 def NFSHandle(key, event) event = deep_copy(event) Builtins.y2debug("NFSHandle: key: %1, event: %2", key, event) if Ops.get(event, "ID") == :nfs_browse server = Convert.to_string(UI.QueryWidget(Id(:server), :Value)) # dialog caption result = NetworkPopup.NFSServer(server) UI.ChangeWidget(Id(:server), :Value, result) if result != nil elsif Ops.get(event, "ID") == :nfs_exports_browse server = Convert.to_string(UI.QueryWidget(Id(:server), :Value)) nfs_export = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) # dialog caption result = NetworkPopup.NFSExport(server, nfs_export) UI.ChangeWidget(Id(:dir), :Value, result) if result != nil elsif (Ops.get(event, "ID") == :edit_url_parts || Ops.get(event, "ID") == :edit_complete_url) && Ops.get_string(event, "EventReason", "") == "ValueChanged" Builtins.y2milestone("Changing dialog type: %1", Ops.get(event, "ID")) # store the current settings if Ops.get(event, "ID") == :edit_url_parts NFSStoreComplete() else NFSStoreParts() end # reinitialize the dialog (set the current values) NFSInit(nil) end nil end |
- (Object) NFSInit(key)
Init function of a widget
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 |
# File '../../src/modules/SourceDialogs.rb', line 562 def NFSInit(key) # check the current edit type current_type = Convert.to_symbol(UI.QueryWidget(Id(:edit_type), :Value)) Builtins.y2debug("Current edit type: %1", current_type) UI.ReplaceWidget( Id(:edit_content), current_type == :edit_url_parts ? @nfs_details_content : @nfs_complete_content ) if current_type == :edit_url_parts iso = IsISOURL(@_url) repo_url = @_url repo_url = PreprocessISOURL(repo_url) if iso parsed = URL.Parse(repo_url) UI.ChangeWidget(Id(:server), :Value, Ops.get_string(parsed, "host", "")) UI.ChangeWidget(Id(:dir), :Value, Ops.get_string(parsed, "path", "")) UI.ChangeWidget(Id(:ch_iso), :Value, iso) UI.SetFocus(:server) query_map = URL.MakeMapFromParams(Ops.get_string(parsed, "query", "")) nfs4 = Builtins.tolower(Ops.get_string(parsed, "scheme", "nfs")) == "nfs4" || Ops.get_string(query_map, "type", "") == "nfs4" if Ops.get_string(parsed, "query", "") != "" UI.ChangeWidget( Id(:mount_options), :Value, Ops.get_string(query_map, "mountoptions", "") ) end Builtins.y2milestone("NFSv4: %1", nfs4) UI.ChangeWidget(Id(:ch_nfs4), :Value, nfs4) else UI.ChangeWidget(Id(:complete_url), :Value, @_url) end nil end |
- (Object) NFSStore(key, event)
Store function of a widget
658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File '../../src/modules/SourceDialogs.rb', line 658 def NFSStore(key, event) event = deep_copy(event) current_type = Convert.to_symbol(UI.QueryWidget(Id(:edit_type), :Value)) Builtins.y2milestone("Current edit type: %1", current_type) if current_type == :edit_url_parts NFSStoreParts() else NFSStoreComplete() end nil end |
- (Object) NFSStoreComplete
649 650 651 652 653 |
# File '../../src/modules/SourceDialogs.rb', line 649 def NFSStoreComplete @_url = Convert.to_string(UI.QueryWidget(Id(:complete_url), :Value)) nil end |
- (Object) NFSStoreParts
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 |
# File '../../src/modules/SourceDialogs.rb', line 608 def NFSStoreParts parsed = { "scheme" => "nfs", "host" => NormalizeHost( Convert.to_string(UI.QueryWidget(Id(:server), :Value)) ), "path" => Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) } nfs4 = Convert.to_boolean(UI.QueryWidget(Id(:ch_nfs4), :Value)) if nfs4 # keep nfs4:// if it is used in the original URL if Builtins.tolower(Ops.get_string(URL.Parse(@_url), "scheme", "")) == "nfs4" Ops.set(parsed, "scheme", "nfs4") else Ops.set(parsed, "query", "type=nfs4") end end @_url = URL.Build(parsed) iso = Convert.to_boolean(UI.QueryWidget(Id(:ch_iso), :Value)) # workaround: URL::Build does not accept numbers in scheme, # for nfs4 scheme it returns URL with no scheme (like "://foo/bar") @_url = Ops.add("nfs4", @_url) if !Builtins.regexpmatch(@_url, "^nfs") @_url = PostprocessISOURL(@_url) if iso if UI.QueryWidget(Id(:mount_options), :Value) != :default mount_opts = Convert.to_string( UI.QueryWidget(Id(:mount_options), :Value) ) @_url = Ops.add( Ops.add(@_url, "?mountoptions="), URL.EscapeString(mount_opts, URL.transform_map_filename) ) end nil end |
- (Object) NFSWidget
Get widget description map
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 |
# File '../../src/modules/SourceDialogs.rb', line 715 def NFSWidget { "widget" => :custom, "custom_widget" => VBox( RadioButtonGroup( Id(:edit_type), HBox( RadioButton( Id(:edit_url_parts), Opt(:notify), _("Edit Parts of the URL"), true ), HSpacing(2), RadioButton( Id(:edit_complete_url), Opt(:notify), _("Edit Complete URL") ) ) ), ReplacePoint(Id(:edit_content), Empty()) ), "init" => fun_ref(method(:NFSInit), "void (string)"), "store" => fun_ref(method(:NFSStore), "void (string, map)"), "handle" => fun_ref(method(:NFSHandle), "symbol (string, map)"), # help text "help" => Ops.add( Ops.add( _( "<p><big><b>NFS Server</b></big><br>\n" + "Use <b>Server Name</b> and <b>Path to Directory or ISO Image</b>\n" + "to specify the NFS server host name and path on the server.</p>" ), @multi_cd_help ), _( "<p><big><b>Mount Options</b></big><br>\n" + "You can specify extra options used for mounting the NFS volume.\n" + "This is an expert option, keeping the default value is recommened. See <b>man 5 nfs</b>\n" + "for details and the list of supported options." ) ) } end |
- (String) NormalizeHost(host)
Remove leading and trailing (and inner) spaces from the host name
379 380 381 382 |
# File '../../src/modules/SourceDialogs.rb', line 379 def NormalizeHost(host) host = Builtins.deletechars(host, " \t") host end |
- (Boolean) PathIsISO(url)
check if given path points to ISO file
363 364 365 366 |
# File '../../src/modules/SourceDialogs.rb', line 363 def PathIsISO(url) return false if Ops.less_than(Builtins.size(url), 4) Builtins.substring(url, Ops.subtract(Builtins.size(url), 4), 4) == ".iso" end |
- (Object) PlainURLInit(key)
Init function of a widget
502 503 504 505 506 507 |
# File '../../src/modules/SourceDialogs.rb', line 502 def PlainURLInit(key) UI.ChangeWidget(Id(:url), :Value, @_url) UI.SetFocus(:url) nil end |
- (Object) PlainURLStore(key, event)
Store function of a widget
512 513 514 515 516 517 |
# File '../../src/modules/SourceDialogs.rb', line 512 def PlainURLStore(key, event) event = deep_copy(event) @_url = Convert.to_string(UI.QueryWidget(Id(:url), :Value)) nil end |
- (Object) PlainURLValidate(key, event)
519 520 521 522 523 524 525 526 527 528 529 |
# File '../../src/modules/SourceDialogs.rb', line 519 def PlainURLValidate(key, event) event = deep_copy(event) url = Convert.to_string(UI.QueryWidget(Id(:url), :Value)) if url == "" UI.SetFocus(Id(:url)) # popup message Popup.Message(_("URL cannot be empty.")) return false end true end |
- (Object) PlainURLWidget
Get widget description map
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
# File '../../src/modules/SourceDialogs.rb', line 533 def PlainURLWidget { "widget" => :custom, "custom_widget" => VBox( # text entry InputField(Id(:url), Opt(:hstretch), _("&URL")) ), "init" => fun_ref(method(:PlainURLInit), "void (string)"), "store" => fun_ref( method(:PlainURLStore), "void (string, map)" ), "validate_type" => :function, "validate_function" => fun_ref( method(:PlainURLValidate), "boolean (string, map)" ), # help text "help" => Ops.add( _( "<p><big><b>Repository URL</b></big><br>\nUse <b>URL</b> to specify the URL of the repository.</p>" ), @multi_cd_help ) } end |
- (Object) PopupButtons
Return an HBox with ok and cancel buttons for use by other dialogs.
386 387 388 389 390 391 392 |
# File '../../src/modules/SourceDialogs.rb', line 386 def PopupButtons HBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), HSpacing(2), PushButton(Id(:cancel), Label.CancelButton) ) end |
- (Yast::Term) PopupContents(proto, repository)
Get contents of a popup for specified protocol
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 |
# File '../../src/modules/SourceDialogs.rb', line 2422 def PopupContents(proto, repository) VBox( HSpacing(50), # label Heading(Ops.get(@_caption, proto, "")), repository ? "repo_name" : "service_name", VSpacing(0.4), proto, VSpacing(0.4), PopupButtons() ) end |
- (String) PostprocessISOURL(url)
Postprocess URL of an ISO image
319 320 321 322 323 324 325 326 327 328 329 |
# File '../../src/modules/SourceDialogs.rb', line 319 def PostprocessISOURL(url) Builtins.y2milestone("Updating ISO URL %1", URL.HidePassword(url)) last = Ops.add(Builtins.findlastof(url, "/"), 1) onlydir = Builtins.substring(url, 0, last) url = Ops.add( Ops.add(Ops.add("iso:///?iso=", Builtins.substring(url, last)), "&url="), onlydir ) Builtins.y2milestone("Updated URL: %1", URL.HidePassword(url)) url end |
- (String) PreprocessISOURL(url)
Preprocess the ISO URL to be used in the dialogs
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File '../../src/modules/SourceDialogs.rb', line 344 def PreprocessISOURL(url) Builtins.y2milestone("Preprocessing ISO URL %1", URL.HidePassword(url)) url_pt = Builtins.search(url, "&url=") serverpart = Builtins.substring(url, Ops.add(url_pt, 5)) isopart = Builtins.substring(url, 0, url_pt) url = Ops.add( serverpart, Builtins.substring( isopart, Ops.add(Builtins.search(isopart, "iso="), 4) ) ) Builtins.y2milestone("Updated URL: %1", URL.HidePassword(url)) url end |
- (Object) RefreshTypeWidgets
2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 |
# File '../../src/modules/SourceDialogs.rb', line 2304 def RefreshTypeWidgets if UI.WidgetExists(:add_addon) enabled = UI.QueryWidget(Id(:add_addon), :Value) WIDGET_LABELS.keys.each do || UI.ChangeWidget(Id(), :Enabled, enabled) if UI.WidgetExists() end UI.ChangeWidget(Id(:type), :Enabled, enabled) if UI.WidgetExists(:type) end end |
- (Object) RepoNameInit(key)
Init function of a widget
419 420 421 422 423 |
# File '../../src/modules/SourceDialogs.rb', line 419 def RepoNameInit(key) UI.ChangeWidget(Id(:repo_name), :Value, @_repo_name) nil end |
- (Object) RepoNameStore(key, event)
Store function of a widget
428 429 430 431 432 433 |
# File '../../src/modules/SourceDialogs.rb', line 428 def RepoNameStore(key, event) event = deep_copy(event) @_repo_name = Convert.to_string(UI.QueryWidget(Id(:repo_name), :Value)) nil end |
- (Object) RepoNameValidate(key, event)
435 436 437 438 439 440 441 442 443 444 445 |
# File '../../src/modules/SourceDialogs.rb', line 435 def RepoNameValidate(key, event) event = deep_copy(event) repo_name = Convert.to_string(UI.QueryWidget(Id(:repo_name), :Value)) if repo_name == "" && @_repo_name != "" # do not fail on new repo creation UI.SetFocus(Id(:repo_name)) # popup message Popup.Message(_("The name of the repository cannot be empty.")) return false end true end |
- (Object) RepoNameWidget
Get widget description map
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 |
# File '../../src/modules/SourceDialogs.rb', line 448 def RepoNameWidget { "widget" => :custom, "custom_widget" => VBox( # text entry InputField(Id(:repo_name), Opt(:hstretch), _("&Repository Name")) ), "init" => fun_ref(method(:RepoNameInit), "void (string)"), "store" => fun_ref( method(:RepoNameStore), "void (string, map)" ), "validate_type" => :function, # TODO FIXME: RepoName can be empty if the URL has been changed, # yast will use the product name or the URL in this case (the repository is recreated) "validate_function" => fun_ref( method(:RepoNameValidate), "boolean (string, map)" ), # help text "help" => _( "<p><big><b>Repository Name</b></big><br>\nUse <b>Repository Name</b> to specify the name of the repository. If it is empty, YaST will use the product name (if available) or the URL as the name.</p>\n" ) } end |
- (Object) scc_repos_widget
1968 1969 1970 1971 1972 1973 |
# File '../../src/modules/SourceDialogs.rb', line 1968 def display_scc = WFM.ClientExists("inst_scc") && !Stage.initial log.info "Displaying SCC option: #{display_scc}" display_scc ? Left(RadioButton(Id(:sccrepos), _(WIDGET_LABELS[:sccrepos]))) : Empty() end |
- (Symbol) SelectHandle(key, event)
Handles Ui events in New repository type selection dialog
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 |
# File '../../src/modules/SourceDialogs.rb', line 2168 def SelectHandle(key, event) case event["ID"] when :back # reset the preselected URL when going back @_url = "" return nil when :add_addon RefreshTypeWidgets() return nil end return nil if event["ID"] != :next && event["ID"] != :ok # TODO: disable "download" option when CD or DVD source is selected selected = UI.QueryWidget(Id(:type), :CurrentButton) return :finish if [:slp, :cd, :dvd, :comm_repos, :sccrepos].include?(selected) nil end |
- (Object) SelectInit(key)
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 |
# File '../../src/modules/SourceDialogs.rb', line 2259 def SelectInit(key) current = nil if @_url == "ftp://" current = :ftp elsif @_url == "http://" current = :http elsif @_url == "https://" current = :https elsif @_url == "smb://" current = :samba elsif @_url == "nfs://" current = :nfs elsif @_url == "nfs4://" current = :nfs elsif @_url == "cd:///" current = :cd elsif @_url == "dvd:///" current = :dvd elsif @_url == "hd://" current = :hd elsif @_url == "usb://" current = :usb elsif @_url == "dir://" current = :local_dir elsif @_url == "file://" current = :local_iso elsif @_url == "slp://" current = :slp elsif @_url == "commrepos://" current = :comm_repos elsif @_url == "sccrepos://" current = :sccrepos else Builtins.y2warning("Unknown URL scheme '%1'", @_url) current = :specify_url end UI.ChangeWidget(Id(:type), :CurrentButton, current) if current != nil RefreshTypeWidgets() nil end |
- (Object) SelectRadioWidget
2074 2075 2076 |
# File '../../src/modules/SourceDialogs.rb', line 2074 def SelectRadioWidget SelectRadioWidgetOpt(false) end |
- (Object) SelectRadioWidgetDL
2078 2079 2080 |
# File '../../src/modules/SourceDialogs.rb', line 2078 def SelectRadioWidgetDL SelectRadioWidgetOpt(true) end |
- (Object) SelectRadioWidgetOpt(download_widget)
FIXME: two almost same definitions in the same function smell bad
1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 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 2069 2070 2071 2072 |
# File '../../src/modules/SourceDialogs.rb', line 1976 def SelectRadioWidgetOpt() contents = HBox( HStretch(), VBox( VStretch(), addon_checkbox_term, RadioButtonGroup( Id(:type), VBox( HBox( addon_spacing_term, VBox( # radio button Left(RadioButton(Id(:slp), _(WIDGET_LABELS[:slp]))), # bnc #428370, No need to offer community repositories if not defined CRURLDefined() ? # radio button Left(RadioButton(Id(:comm_repos), _(WIDGET_LABELS[:comm_repos]))) : Empty(), , VSpacing(0.4), Left(RadioButton(Id(:specify_url), _(WIDGET_LABELS[:specify_url]))), VSpacing(0.4), *[:ftp, :http, :https, :samba, :nfs, :cd, :dvd, :hd, :usb, :local_dir, :local_iso].map do |id| Left(RadioButton(Id(id), _(WIDGET_LABELS[id]))) end, ? VBox( VSpacing(2), Left( CheckBox( Id(:download_metadata), _(WIDGET_LABELS[:download_metadata]), @_download_metadata ) ) ) : Empty(), VStretch() ) ) ) ) ), HStretch() ) if !IsAnyNetworkAvailable() Builtins.y2milestone( "Network is not available, skipping all Network-related options..." ) contents = HBox( HStretch(), VBox( VStretch(), addon_checkbox_term, RadioButtonGroup( Id(:type), VBox( HBox( addon_spacing_term, VBox( Left(RadioButton(Id(:specify_url), _(WIDGET_LABELS[:specify_url]))), VSpacing(0.4), *[:cd, :dvd, :hd, :usb, :local_dir, :local_iso].map do |id| Left(RadioButton(Id(id), _(WIDGET_LABELS[id]))) end, ? VBox( VSpacing(2), Left( CheckBox( Id(:download_metadata), _(WIDGET_LABELS[:download_metadata]), @_download_metadata ) ) ) : Empty(), VStretch() ) ) ) ) ), HStretch() ) else Builtins.y2milestone( "Network is available, allowing Network-related options..." ) end deep_copy(contents) end |
- (Object) SelectStore(key, event)
2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 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 |
# File '../../src/modules/SourceDialogs.rb', line 2189 def SelectStore(key, event) event = deep_copy(event) @_url = "" @_plaindir = false @_repo_name = "" @addon_enabled = UI.WidgetExists(:add_addon) ? UI.QueryWidget(:add_addon, :Value) : nil selected = Convert.to_symbol(UI.QueryWidget(Id(:type), :CurrentButton)) if Builtins.contains( [ :ftp, :http, :https, :samba, :nfs, :cd, :dvd, :usb, :hd, :local_dir, :specify_url, :slp, :local_iso, :sccrepos, :comm_repos ], selected ) if selected == :ftp @_url = "ftp://" elsif selected == :http @_url = "http://" elsif selected == :https @_url = "https://" elsif selected == :samba @_url = "smb://" elsif selected == :nfs @_url = "nfs://" elsif selected == :cd || selected == :dvd @_url = selected == :cd ? "cd:///" : "dvd:///" if @cd_device_name != "" @_url = Ops.add( Ops.add(@_url, "?devices="), URLRecode.EscapeQuery(@cd_device_name) ) end elsif selected == :hd @_url = "hd://" elsif selected == :usb @_url = "usb://" elsif selected == :local_dir @_url = "dir://" elsif selected == :local_iso @_url = "file://" elsif selected == :slp @_url = "slp://" elsif selected == :comm_repos @_url = "commrepos://" elsif selected == :sccrepos @_url = "sccrepos://" end else Builtins.y2error("Unexpected repo type %1", selected) end nil end |
- (Object) SelectStoreDl(key, event)
2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 |
# File '../../src/modules/SourceDialogs.rb', line 2347 def SelectStoreDl(key, event) event = deep_copy(event) SelectStore(key, event) @_download_metadata = Convert.to_boolean( UI.QueryWidget(Id(:download_metadata), :Value) ) nil end |
- (Object) SelectValidate(key, event)
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 |
# File '../../src/modules/SourceDialogs.rb', line 2126 def SelectValidate(key, event) event = deep_copy(event) selected = Convert.to_symbol(UI.QueryWidget(Id(:type), :CurrentButton)) if selected == nil # error popup Popup.Message(_("Select the media type")) return false end if selected == :cd || selected == :dvd Pkg.SourceReleaseAll msg = selected == :cd ? _("Insert the add-on product CD") : _("Insert the add-on product DVD") # reset the device name @cd_device_name = "" # ask for a medium ui_result = SourceManager.AskForCD(msg) return false if !Ops.get_boolean(ui_result, "continue", false) cd_device = Ops.get_string(ui_result, "device", "") if cd_device != nil && cd_device != "" Builtins.y2milestone("Selected CD/DVD device: %1", cd_device) @cd_device_name = cd_device end elsif selected == :usb usb_disks = DetectUSBDisk() if Builtins.size(usb_disks) == 0 Report.Error(_("No USB disk was detected.")) return false end end true end |
- (Object) SelectWidget
2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 |
# File '../../src/modules/SourceDialogs.rb', line 2315 def SelectWidget { "widget" => :func, "widget_func" => fun_ref(method(:SelectRadioWidget), "term ()"), "init" => fun_ref(method(:SelectInit), "void (string)"), "help" => SelectWidgetHelp(), "validate_type" => :function, "validate_function" => fun_ref( method(:SelectValidate), "boolean (string, map)" ), "store" => fun_ref( method(:SelectStore), "void (string, map)" ), "handle" => fun_ref( method(:SelectHandle), "symbol (string, map)" ) } end |
- (Object) SelectWidgetDL
2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 |
# File '../../src/modules/SourceDialogs.rb', line 2368 def SelectWidgetDL { "widget" => :func, "widget_func" => fun_ref(method(:SelectRadioWidgetDL), "term ()"), "init" => fun_ref(method(:SelectInit), "void (string)"), "help" => Ops.add(SelectWidgetHelp(), SelectWidgetHelpDl()), "validate_type" => :function, "validate_function" => fun_ref( method(:SelectValidate), "boolean (string, map)" ), "store" => fun_ref( method(:SelectStoreDl), "void (string, map)" ), "handle" => fun_ref( method(:SelectHandle), "symbol (string, map)" ) } end |
- (Object) SelectWidgetHelp
2083 2084 2085 2086 2087 2088 2089 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 |
# File '../../src/modules/SourceDialogs.rb', line 2083 def SelectWidgetHelp # help text help_text = _( "<p><big><b>Media Type</b></big><br>\n" + "The software repository can be located on CD, on a network server,\n" + "or on the hard disk.</p>" ) # help, continued help_text = Ops.add( help_text, _( "<p>\n" + "To add <b>CD</b> or <b>DVD</b>,\n" + "have the product CD set or the DVD available.</p>" ) ) # help, continued help_text = Ops.add( help_text, _( "<p>\n" + "The product CDs can be copied to the hard disk.\n" + "Enter the path to the first CD, for example, /data1/<b>CD1</b>.\n" + "Only the base path is required if all CDs are copied\n" + "into the same directory.</p>\n" ) ) # help, continued help_text = Ops.add( help_text, _( "<p>\n" + "Network installation requires a working network connection.\n" + "Specify the directory in which the packages from\n" + "the first CD are located, such as /data1/CD1.</p>\n" ) ) help_text end |
- (Object) SelectWidgetHelpDl
2358 2359 2360 2361 2362 2363 2364 2365 2366 |
# File '../../src/modules/SourceDialogs.rb', line 2358 def SelectWidgetHelpDl _( "<p><b>Download Files</b><br>\n" + "Each repository has description files which describe the content of the\n" + "repository. Check <b>Download repository description files</b> to download the\n" + "files when closing this YaST module. If the option is unchecked, YaST will\n" + "automatically download the files when it needs them later. </p>\n" ) end |
- (Object) ServerHandle(key, event)
Handle function of a widget
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 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 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 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 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 1680 1681 1682 1683 1684 |
# File '../../src/modules/SourceDialogs.rb', line 1529 def ServerHandle(key, event) event = deep_copy(event) Builtins.y2milestone("ServerHandle: %1, %2", key, event) current_type = Convert.to_symbol(UI.QueryWidget(Id(:edit_type), :Value)) Builtins.y2debug("Current edit type: %1", current_type) id = Ops.get(event, "ID") if Ops.is_symbol?(id) && Builtins.contains( [:http, :https, :ftp, :samba, :rb_type], Convert.to_symbol(id) ) && current_type == :edit_url_parts type = Convert.to_symbol(UI.QueryWidget(Id(:rb_type), :CurrentButton)) server = UI.WidgetExists(Id(:server)) ? Convert.to_string(UI.QueryWidget(Id(:server), :Value)) : "" dir = UI.WidgetExists(Id(:dir)) ? Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) : "" anonymous = UI.WidgetExists(Id(:anonymous)) ? Convert.to_boolean(UI.QueryWidget(Id(:anonymous), :Value)) : false username = UI.WidgetExists(Id(:username)) ? Convert.to_string(UI.QueryWidget(Id(:username), :Value)) : "" password = UI.WidgetExists(Id(:password)) ? Convert.to_string(UI.QueryWidget(Id(:password), :Value)) : "" port = UI.WidgetExists(Id(:port)) ? Convert.to_string(UI.QueryWidget(Id(:port), :Value)) : "" = VBox( HBox( # text entry InputField(Id(:server), Opt(:hstretch), _("Server &Name"), server), type == :http || type == :https ? HBox( HSpacing(1), HSquash(InputField(Id(:port), _("&Port"), port)) ) : Empty(), type == :samba ? # text entry InputField(Id(:share), Opt(:hstretch), _("&Share")) : Empty() ), type == :samba ? VBox( InputField( Id(:dir), Opt(:hstretch), # text entry _("&Path to Directory or ISO Image"), dir ), # checkbox label Left(CheckBox(Id(:ch_iso), _("ISO &Image"))) ) : # text entry InputField(Id(:dir), Opt(:hstretch), _("&Directory on Server"), dir), HBox( HSpacing(0.5), # frame Frame( _("Au&thentication"), VBox( Left( CheckBox( Id(:anonymous), Opt(:notify), # check box _("&Anonymous"), anonymous ) ), type == :samba ? # text entry InputField( Id(:workgroup), Opt(:hstretch), _("&Workgroup or Domain") ) : Empty(), # text entry VSpacing(0.4), HBox( InputField( Id(:username), Opt(:hstretch), _("&User Name"), username ), # password entry Password( Id(:password), Opt(:hstretch), _("&Password"), password ) ) ) ), HSpacing(0.5) ) ) UI.ReplaceWidget(Id(:server_rp), ) if UI.WidgetExists(Id(:port)) # maximum port number is 65535 UI.ChangeWidget(Id(:port), :InputMaxLength, 5) # allow only numbers in the port spec UI.ChangeWidget(Id(:port), :ValidChars, String.CDigit) end # update widget status UI.ChangeWidget(Id(:username), :Enabled, !anonymous) UI.ChangeWidget(Id(:password), :Enabled, !anonymous) if UI.WidgetExists(Id(:workgroup)) UI.ChangeWidget(Id(:workgroup), :Enabled, !anonymous) end InitFocusServerInit(Convert.to_symbol(id)) return nil end if Ops.get(event, "ID") == :anonymous && current_type == :edit_url_parts anonymous = Convert.to_boolean(UI.QueryWidget(Id(:anonymous), :Value)) UI.ChangeWidget(Id(:username), :Enabled, !anonymous) UI.ChangeWidget(Id(:password), :Enabled, !anonymous) if UI.WidgetExists(Id(:workgroup)) UI.ChangeWidget(Id(:workgroup), :Enabled, !anonymous) end return nil elsif (id == :edit_url_parts || id == :edit_complete_url) && Ops.get_string(event, "EventReason", "") == "ValueChanged" Builtins.y2milestone("Changing dialog type") # store the current values (note: the radio button just has been switched, compare to the opposite value!) if id == :edit_url_parts ServerStoreComplete() else ServerStoreParts() end @editing_parts = id == :edit_url_parts # reinitialize the dialog (set the current values) ServerInit(nil) end nil end |
- (Object) ServerInit(key)
1685 1686 1687 1688 1689 1690 1691 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 1723 1724 1725 1726 1727 1728 1729 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 1758 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 |
# File '../../src/modules/SourceDialogs.rb', line 1685 def ServerInit(key) # check the current edit type current_type = @editing_parts ? :edit_url_parts : :edit_complete_url # set the stored value UI.ChangeWidget(Id(:edit_type), :Value, current_type) Builtins.y2debug("Current edit type: %1", current_type) UI.ReplaceWidget( Id(:edit_content), current_type == :edit_url_parts ? @details_content : @complete_content ) if current_type == :edit_url_parts protocol_box = HBox( HStretch(), # radio button RadioButton(Id(:ftp), Opt(:notify), _("&FTP")), HStretch(), # radio button RadioButton(Id(:http), Opt(:notify), _("H&TTP")), HStretch() ) if @_allow_https protocol_box = Builtins.add( protocol_box, # radio button RadioButton(Id(:https), Opt(:notify), _("HTT&PS")) ) protocol_box = Builtins.add(protocol_box, HStretch()) end protocol_box = Builtins.add( protocol_box, # radio button RadioButton(Id(:samba), Opt(:notify), _("&SMB/CIFS")) ) protocol_box = Builtins.add(protocol_box, HStretch()) protocol_box = RadioButtonGroup( Id(:rb_type), Opt(:notify), protocol_box ) UI.ReplaceWidget(Id(:rb_type_rp), protocol_box) iso = IsISOURL(@_url) @_url = PreprocessISOURL(@_url) if iso parsed = URL.Parse(@_url) type = :ftp if Ops.get_string(parsed, "scheme", "") == "http" type = :http elsif Ops.get_string(parsed, "scheme", "") == "https" type = :https elsif Ops.get_string(parsed, "scheme", "") == "smb" type = :samba end UI.ChangeWidget(Id(:rb_type), :CurrentButton, type) ServerHandle(key, { "ID" => :rb_type }) UI.ChangeWidget(Id(:server), :Value, Ops.get_string(parsed, "host", "")) dir = Ops.get_string(parsed, "path", "") if type == :samba UI.ChangeWidget(Id(:ch_iso), :Value, iso) sharepath = Builtins.regexptokenize(dir, "^/*([^/]+)(/.*)?$") share = Ops.get_string(sharepath, 0, "") dir = Ops.get_string(sharepath, 1, "") dir = "/" if dir == nil UI.ChangeWidget( Id(:workgroup), :Value, Ops.get_string(parsed, "domain", "") ) UI.ChangeWidget(Id(:share), :Value, share) end UI.ChangeWidget(Id(:dir), :Value, dir) UI.ChangeWidget( Id(:username), :Value, Ops.get_string(parsed, "user", "") ) UI.ChangeWidget( Id(:password), :Value, Ops.get_string(parsed, "pass", "") ) anonymous = !(Ops.get_string(parsed, "user", "") != "" || Ops.get_string(parsed, "pass", "") != "") Builtins.y2milestone("Anonymous: %1", anonymous) UI.ChangeWidget(Id(:anonymous), :Value, anonymous) if anonymous UI.ChangeWidget(Id(:username), :Enabled, false) UI.ChangeWidget(Id(:password), :Enabled, false) if UI.WidgetExists(Id(:workgroup)) UI.ChangeWidget(Id(:workgroup), :Enabled, !anonymous) end end # set HTTP/HTTPS port if it's specified if type == :http || type == :https port_num = Ops.get_string(parsed, "port", "") if port_num != nil && port_num != "" UI.ChangeWidget(Id(:port), :Value, port_num) end end InitFocusServerInit(type) else UI.ChangeWidget(Id(:complete_url), :Value, @_url) end nil end |
- (Object) ServerStore(key, event)
1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 |
# File '../../src/modules/SourceDialogs.rb', line 1822 def ServerStore(key, event) event = deep_copy(event) Builtins.y2debug("Server store: %1, %2", key, event) current_type = Convert.to_symbol(UI.QueryWidget(Id(:edit_type), :Value)) Builtins.y2debug("Current edit type: %1", current_type) @editing_parts = current_type == :edit_url_parts if @editing_parts ServerStoreParts() else ServerStoreComplete() end nil end |
- (Object) ServerStoreComplete
1519 1520 1521 1522 1523 |
# File '../../src/modules/SourceDialogs.rb', line 1519 def ServerStoreComplete @_url = Convert.to_string(UI.QueryWidget(Id(:complete_url), :Value)) nil end |
- (Object) ServerStoreParts
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 |
# File '../../src/modules/SourceDialogs.rb', line 1408 def ServerStoreParts type = Convert.to_symbol(UI.QueryWidget(Id(:rb_type), :CurrentButton)) # initialize keys to empty values so the new and old values can be simply compared parsed = { "fragment" => "", "host" => "", "pass" => "", "path" => "", "port" => "", "query" => "", "scheme" => "", "user" => "" } if type == :ftp Ops.set(parsed, "scheme", "ftp") elsif type == :http Ops.set(parsed, "scheme", "http") elsif type == :https Ops.set(parsed, "scheme", "https") elsif type == :samba Ops.set(parsed, "scheme", "smb") end anonymous = Convert.to_boolean(UI.QueryWidget(Id(:anonymous), :Value)) if !anonymous user = Convert.to_string(UI.QueryWidget(Id(:username), :Value)) pass = Convert.to_string(UI.QueryWidget(Id(:password), :Value)) Ops.set(parsed, "user", user) if Builtins.size(user) != 0 Ops.set(parsed, "pass", pass) if Builtins.size(pass) != 0 end host = NormalizeHost( Convert.to_string(UI.QueryWidget(Id(:server), :Value)) ) directory = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) # is / in the host name? pos = Builtins.findfirstof(host, "/") if pos != nil # update the hostname and the directory, # URL::Build return empty URL when the hostname is not valid Builtins.y2milestone("The hostname contains a path: %1", host) dir = Builtins.substring(host, pos) if Builtins.substring(dir, Ops.subtract(Builtins.size(dir), 1), 1) != "/" && Builtins.substring(directory, 0, 1) != "/" dir = Ops.add(dir, "/") end directory = Ops.add(dir, directory) host = Builtins.substring(host, 0, pos) Builtins.y2milestone( "Updated hostname: %1, directory: %2", host, directory ) end Ops.set(parsed, "host", host) if type == :samba share = Convert.to_string(UI.QueryWidget(Id(:share), :Value)) directory = Ops.add(Slashed(share), Slashed(directory)) elsif type != :ftp # FTP needs to distinguish absolute and relative path # do not add the slash if host and directory is empty # (avoid e.g. http:// -> http:/// when switching from the parts to the complete view) directory = Slashed(directory) if host != "" || directory != "" end if UI.WidgetExists(Id(:workgroup)) workgroup = Convert.to_string(UI.QueryWidget(Id(:workgroup), :Value)) if type == :samba && Ops.greater_than(Builtins.size(workgroup), 0) Ops.set(parsed, "domain", workgroup) end end Ops.set(parsed, "path", directory) # set HTTP/HTTPS port if type == :http || type == :https Ops.set( parsed, "port", Convert.to_string(UI.QueryWidget(Id(:port), :Value)) ) end # keep the URL if user haven't changed anything (don't change escaped chars bnc#529944) parsed_old = URL.Parse(@_url) if parsed == parsed_old Builtins.y2milestone("No change, NOT updating the complete URL") Builtins.y2debug("Unchanged URL: %1", parsed) else Builtins.y2milestone("A change detected, updating complete URL") Builtins.y2debug("Updating the URL: %1 -> %2", parsed_old, parsed) # do not log the entered password Builtins.y2milestone("Entered URL: %1", URL.HidePasswordToken(parsed)) @_url = URL.Build(parsed) Builtins.y2milestone("URL::Build: %1", URL.HidePassword(@_url)) if UI.WidgetExists(Id(:ch_iso)) iso = Convert.to_boolean(UI.QueryWidget(Id(:ch_iso), :Value)) @_url = PostprocessISOURL(@_url) if iso end end nil end |
- (Object) ServerValidate(key, event)
1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
# File '../../src/modules/SourceDialogs.rb', line 1800 def ServerValidate(key, event) event = deep_copy(event) current_type = Convert.to_symbol(UI.QueryWidget(Id(:edit_type), :Value)) Builtins.y2debug("Current edit type: %1", current_type) if current_type == :edit_url_parts host = NormalizeHost( Convert.to_string(UI.QueryWidget(Id(:server), :Value)) ) if !Hostname.CheckFQ(host) if !IP.Check(host) UI.SetFocus(:server) Popup.Error( Builtins.sformat("%1\n\n%2", Hostname.ValidFQ, IP.Valid4) ) return false end end end true end |
- (Object) ServerWidget
Get widget description map
1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 |
# File '../../src/modules/SourceDialogs.rb', line 1842 def ServerWidget { "widget" => :custom, "custom_widget" => VBox( RadioButtonGroup( Id(:edit_type), HBox( RadioButton( Id(:edit_url_parts), Opt(:notify), _("Edit Parts of the URL"), @editing_parts ), HSpacing(2), RadioButton( Id(:edit_complete_url), Opt(:notify), _("Edit Complete URL"), !@editing_parts ) ) ), VSpacing(0.3), ReplacePoint(Id(:edit_content), Empty()) ), "init" => fun_ref(method(:ServerInit), "void (string)"), "validate_type" => :function, "validate_function" => fun_ref( method(:ServerValidate), "boolean (string, map)" ), "store" => fun_ref( method(:ServerStore), "void (string, map)" ), "handle" => fun_ref( method(:ServerHandle), "symbol (string, map)" ), # help text - server dialog "help" => Ops.add( _( "<p><big><b>Server and Directory</b></big><br>\n" + "Use <b>Server Name</b> and <b>Path to Directory or ISO Image</b>\n" + "to specify the NFS server host name and path on the server.\n" + "To enable authentication, uncheck <b>Anonymous</b> and specify the\n" + "<b>User Name</b> and the <b>Password</b>.</p>\n" + "<p>\n" + "For the SMB/CIFS repository, specify <b>Share</b> name and <b>Path to Directory\n" + "or ISO Image</b>. \n" + "If the location is a file holding an ISO image\n" + "of the media, set <b>ISO Image</b>.</p>\n" ) + # help text - server dialog, there is a "Port" widget _( "<p>It is possible to set the <b>Port</b> number for a HTTP/HTTPS repository.\nLeave it empty to use the default port.</p>\n" ), @multi_cd_help ) } end |
- (Object) ServiceNameWidget
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File '../../src/modules/SourceDialogs.rb', line 474 def ServiceNameWidget ret = RepoNameWidget() Ops.set( ret, "custom_widget", VBox( # text entry InputField(Id(:repo_name), Opt(:hstretch), _("&Service Name")) ) ) # help text Ops.set( ret, "help", _( "<p><big><b>Service Name</b></big><br>\nUse <b>Service Name</b> to specify the name of the service. If it is empty, YaST will use part of the service URL as the name.</p>\n" ) ) deep_copy(ret) end |
- (Object) SetDownloadOption(download)
2341 2342 2343 2344 2345 |
# File '../../src/modules/SourceDialogs.rb', line 2341 def SetDownloadOption(download) @_download_metadata = download nil end |
- (Object) SetFileSystems(selected_fs)
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 |
# File '../../src/modules/SourceDialogs.rb', line 1165 def SetFileSystems(selected_fs) fs_list = [ "auto", "vfat", "ntfs", "ntfs-3g", "ext2", "ext3", "ext4", "reiserfs", "xfs", "jfs", "iso9660" ] items = Builtins.maplist(fs_list) do |fs| Item(Id(fs), fs, fs == selected_fs) end UI.ChangeWidget(Id(:fs), :Items, items) nil end |
- (Object) SetRepoName(repo_name)
Set the RepoName to work with
304 305 306 307 308 |
# File '../../src/modules/SourceDialogs.rb', line 304 def SetRepoName(repo_name) @_repo_name = repo_name nil end |
- (Object) SetURL(url)
Set the URL to work with
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 |
# File '../../src/modules/SourceDialogs.rb', line 232 def SetURL(url) @_url = url parsed = URL.Parse(@_url) # check if it's HDD or USB # convert it to the internal representation if Ops.get_string(parsed, "scheme", "") == "hd" query = Ops.get_string(parsed, "query", "") if Builtins.regexpmatch(query, "device=/dev/disk/by-id/usb-") Ops.set(parsed, "scheme", "usb") @_url = URL.Build(parsed) Builtins.y2milestone( "URL %1 is an USB device, changing the scheme to %2", URL.HidePassword(url), @_url ) end end # reset the plaindir flag @_plaindir = false nil end |
- (Object) SetURLType(url, plaindir_type)
Set the URL to work with, set the plaindir flag (type of the repository)
264 265 266 267 268 269 270 271 |
# File '../../src/modules/SourceDialogs.rb', line 264 def SetURLType(url, plaindir_type) SetURL(url) # set the flag AFTER setting the URL! # SetURL() resets the _plaindir flag @_plaindir = plaindir_type nil end |
- (String) Slashed(urlpart)
Add a slash to the part of url, if it is not already present
371 372 373 374 |
# File '../../src/modules/SourceDialogs.rb', line 371 def Slashed(urlpart) return urlpart if Builtins.substring(urlpart, 0, 1) == "/" Ops.add("/", urlpart) end |
- (Symbol) TypeDialog
Sample implementation of URL type selection dialog
2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 |
# File '../../src/modules/SourceDialogs.rb', line 2575 def TypeDialog Builtins.y2milestone("Running repository type dialog") # dialog caption caption = _("Media Type") ret = CWM.ShowAndRun( { "widget_names" => ["select"], "widget_descr" => Widgets(), "contents" => VBox("select"), "caption" => caption, "back_button" => Label.BackButton, "next_button" => Label.NextButton, "fallback_functions" => @default_cwm_fallback_functions, } ) Builtins.y2milestone("Type dialog returned %1", ret) ret end |
- (Symbol) TypeDialogDownloadOpt
Sample implementation of URL type selection dialog
2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 |
# File '../../src/modules/SourceDialogs.rb', line 2596 def TypeDialogDownloadOpt Builtins.y2milestone( "Running repository type dialog with download option" ) # dialog caption caption = _("Add On Product") ui = CWM.ShowAndRun( { "widget_names" => ["select_dl"], "widget_descr" => Widgets(), "contents" => VBox("select_dl"), "caption" => caption, "back_button" => Label.BackButton, "next_button" => Label.NextButton, "fallback_functions" => @default_cwm_fallback_functions, } ) ret = { "ui" => ui, "download" => @_download_metadata } Builtins.y2milestone("Type dialog returned %1", ret) deep_copy(ret) end |
- (String) TypePopup
URL editation popup with the HTTPS option
2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 |
# File '../../src/modules/SourceDialogs.rb', line 2558 def TypePopup w = CWM.CreateWidgets(["select"], Widgets()) contents = PopupContents("select", true) contents = CWM.PrepareDialog(contents, w) UI.OpenDialog(contents) ret = CWM.Run(w, {}) Builtins.y2milestone("Ret: %1", ret) UI.CloseDialog "" # if (ret == `ok) # return GetURL (); # else # return ""; end |
- (String) URLScheme(url)
Get scheme of a URL, also for ISO URL get scheme of the access protocol
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File '../../src/modules/SourceDialogs.rb', line 397 def URLScheme(url) scheme = "" if IsISOURL(url) tmp_url = PreprocessISOURL(url) parsed = URL.Parse(tmp_url) scheme = Ops.get_string(parsed, "scheme", "") else parsed = URL.Parse(url) scheme = Ops.get_string(parsed, "scheme", "") end scheme = "url" if scheme == "" || scheme == nil Builtins.y2milestone( "URL scheme for URL %1: %2", URL.HidePassword(url), scheme ) scheme end |
- (Object) USBInit(key)
Init function of a widget
1216 1217 1218 1219 1220 1221 1222 |
# File '../../src/modules/SourceDialogs.rb', line 1216 def USBInit(key) # detect disks usb_disks = DetectUSBDisk() InitDiskWidget(usb_disks) nil end |
- (Object) USBStore(key, event)
Store function of a widget
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 |
# File '../../src/modules/SourceDialogs.rb', line 1227 def USBStore(key, event) event = deep_copy(event) # build URL like this: usb:///openSUSE?device=/dev/sdb8&filesystem=auto query = Builtins.sformat( "device=%1&filesystem=%2", Convert.to_string(UI.QueryWidget(Id(:disk), :Value)), Convert.to_string(UI.QueryWidget(Id(:fs), :Value)) ) dir = Convert.to_string(UI.QueryWidget(Id(:dir), :Value)) @_plaindir = Convert.to_boolean(UI.QueryWidget(Id(:ch_plain), :Value)) parsed = { "scheme" => "usb", "path" => dir, "query" => query } @_url = URL.Build(parsed) Builtins.y2milestone("New USB url: %1", URL.HidePassword(@_url)) nil end |
- (Object) USBWidget
Get widget description map
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 |
# File '../../src/modules/SourceDialogs.rb', line 1252 def USBWidget { "widget" => :custom, "custom_widget" => VBox( # combobox title Left( ComboBox( Id(:disk), #`opt(`hstretch), _("&USB Mass Storage Device") + # the spacing is added to make the widget wider " " ) ), Left(ComboBox(Id(:fs), Opt(:editable), _("&File System"))), Left(InputField(Id(:dir), _("Dire&ctory"))), Left(CheckBox(Id(:ch_plain), _("&Plain RPM Directory"))) ), "init" => fun_ref(method(:USBInit), "void (string)"), "store" => fun_ref(method(:USBStore), "void (string, map)"), "help" => _( "<p><big><b>USB Stick or Disk</b></big><br>\n" + "Select the USB device on which the repository is located.\n" + "Use <b>Path to Directory</b> to specify the directory of the repository.\n" + "If the path is omitted, the system will use the root directory of the disk.\n" + "If the directory contains only RPM packages without\n" + "any metadata (i.e. there is no product information), then check option\n" + "<b>Plain RPM Directory</b>.</p>\n" ) + # 'auto' is a value in the combo box widget, do not translate it! _( "<p>The file system used on the device will be detected automatically\n" + "if you select file system 'auto'. If the detection fails or you\n" + "want to use a certain file system, select it from the list.</p>\n" ) } end |
- (Object) Widgets
Get individual widgets
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 |
# File '../../src/modules/SourceDialogs.rb', line 2392 def Widgets if Builtins.size(@_widgets) == 0 @_widgets = { "repo_name" => RepoNameWidget(), "service_name" => ServiceNameWidget(), "url" => PlainURLWidget(), "nfs" => NFSWidget(), "cd" => CDWidget(), "dvd" => CDWidget(), "hd" => DiskWidget(), "usb" => USBWidget(), "dir" => DirWidget(), "file" => IsoWidget(), "http" => ServerWidget(), "https" => ServerWidget(), "ftp" => ServerWidget(), "smb" => ServerWidget(), "cifs" => ServerWidget(), "select" => SelectWidget(), "select_dl" => SelectWidgetDL() } end deep_copy(@_widgets) end |