Module: Yast::TftpServerDialogsInclude
- Defined in:
- ../../src/include/tftp-server/dialogs.rb
Instance Method Summary (collapse)
- - (Object) CheckDirectorySyntax(dir)
- - (Object) initialize_tftp_server_dialogs(include_target)
-
- (Object) MainDialog
Main dialog.
-
- (Object) Packages
Check for required packaged to be installed.
-
- (Object) ReadDialog
Read settings dialog.
- - (Object) TextAndButton(text, button)
-
- (Object) WriteDialog
Write settings dialog.
Instance Method Details
- (Object) CheckDirectorySyntax(dir)
233 234 235 236 |
# File '../../src/include/tftp-server/dialogs.rb', line 233 def CheckDirectorySyntax(dir) Builtins.substring(dir, 0, 1) == "/" && Builtins.filterchars(" \t", dir) == "" end |
- (Object) initialize_tftp_server_dialogs(include_target)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File '../../src/include/tftp-server/dialogs.rb', line 11 def initialize_tftp_server_dialogs(include_target) Yast.import "UI" textdomain "tftp-server" Yast.import "CWMFirewallInterfaces" Yast.import "Label" Yast.import "LogView" Yast.import "Message" Yast.import "Mode" Yast.import "Package" Yast.import "Popup" Yast.import "TftpServer" Yast.import "Wizard" end |
- (Object) MainDialog
Main dialog
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 |
# File '../../src/include/tftp-server/dialogs.rb', line 59 def MainDialog Wizard.SetScreenShotName("tftp-server-1-main") start = TftpServer.start directory = TftpServer.directory changed = false # Tftp-server dialog caption caption = _("TFTP Server Configuration") # firewall widget using CWM fw_settings = { "services" => ["service:tftp"], "display_details" => true } = CWMFirewallInterfaces.CreateOpenFirewallWidget( fw_settings ) # dialog help text help_text = _("<p><big><b>Configuring a TFTP Server</b></big></p>") # dialog help text help_text = Ops.add( help_text, _( "<p>Use this to enable a server for TFTP (trivial file transfer protocol). The server will be started using xinetd.</p>" ) ) # enlighten newbies, #102946 # dialog help text help_text = Ops.add( help_text, _("<p>Note that TFTP and FTP are not the same.</p>") ) # dialog help text help_text = Ops.add( help_text, _( "<p><b>Boot Image Directory</b>:\n" + "Specify the directory where served files are located. The usual value is\n" + "<tt>/tftpboot</tt>. The directory will be created if it does not exist. \n" + "The server uses this as its root directory (using the <tt>-s</tt> option).</p>\n" ) ) help_text = Ops.add(help_text, Ops.get_string(, "help", "")) contents = HVSquash( VBox( RadioButtonGroup( Id(:rbg), VBox( Left( RadioButton( Id(:tftpno), Opt(:notify), # Radio button label, disable TFTP server _("&Disable"), !start ) ), Left( RadioButton( Id(:tftpyes), Opt(:notify), # Radio button label, disable TFTP server _("&Enable"), start ) ) ) ), VSpacing(1), TextAndButton( # Text entry label # Directory where served files (usually boot images) reside TextEntry(Id(:directory), _("&Boot Image Directory"), directory), # push button label # select a directory from the filesystem PushButton(Id(:browse), _("Bro&wse...")) ), VSpacing(1), Ops.get_term(, "custom_widget", Empty()), VSpacing(2), # push button label # display a log file PushButton(Id(:viewlog), _("&View Log")) ) ) Wizard.SetContentsButtons( caption, contents, help_text, Label.BackButton, Label.OKButton ) Wizard.HideBackButton Wizard.SetAbortButton(:abort, Label.CancelButton) # initialize the widget (set the current value) CWMFirewallInterfaces.OpenFirewallInit(, "") UI.ChangeWidget(Id(:viewlog), :Enabled, !Mode.config) event = nil ret = nil begin UI.ChangeWidget(Id(:directory), :Enabled, start) UI.ChangeWidget(Id(:browse), :Enabled, start) event = UI.WaitForEvent ret = Ops.get(event, "ID") ret = :abort if ret == :cancel # handle the events, enable/disable the button, show the popup if button clicked CWMFirewallInterfaces.OpenFirewallHandle(, "", event) start = UI.QueryWidget(Id(:rbg), :CurrentButton) == :tftpyes directory = Convert.to_string(UI.QueryWidget(Id(:directory), :Value)) # discard the difference in disabled fields: # directory is only considered if start is on changed = CWMFirewallInterfaces.OpenFirewallModified("") || start != TftpServer.start || # "" because method doesn't use parameter at all, nice :( start && directory != TftpServer.directory if ret == :browse directory = UI.AskForExistingDirectory( directory != "" ? directory : "/", "" ) UI.ChangeWidget(Id(:directory), :Value, directory) if directory != nil elsif ret == :viewlog LogView.DisplayFiltered("/var/log/messages", "\\(tftp\\|TFTP\\)") end # validity checks if ret == :next && start if CheckDirectorySyntax(directory) #ok, say that it will be created if !Mode.config && Ops.less_than(SCR.Read(path(".target.size"), directory), 0) # the dir does not exist ret = Popup.YesNo(Message.DirectoryDoesNotExistCreate(directory)) ? ret : nil end else UI.SetFocus(Id(:directory)) # error popup Popup.Error( _( "The directory must start with a slash (/)\nand must not contain spaces." ) ) ret = nil end end end until ret == :next || (ret == :back || ret == :abort) && (!changed || Popup.ReallyAbort(true)) if ret == :next # grab current settings, store them to SuSEFirewall:: CWMFirewallInterfaces.OpenFirewallStore(, "", event) TftpServer.start = start TftpServer.directory = directory if start end Wizard.RestoreScreenShotName Convert.to_symbol(ret) end |
- (Object) Packages
Check for required packaged to be installed
30 31 32 33 34 |
# File '../../src/include/tftp-server/dialogs.rb', line 30 def Packages return :abort if !Package.InstallAll(TftpServer.required_packages) :next end |
- (Object) ReadDialog
Read settings dialog
38 39 40 41 42 43 44 45 46 47 48 |
# File '../../src/include/tftp-server/dialogs.rb', line 38 def ReadDialog ret = true ret = ret && TftpServer.Read if TftpServer.foreign_servers != "" Popup.Error(TftpServer.ForeignServersError) ret = false end ret ? :next : :abort end |
- (Object) TextAndButton(text, button)
228 229 230 231 232 |
# File '../../src/include/tftp-server/dialogs.rb', line 228 def TextAndButton(text, ) text = deep_copy(text) = deep_copy() HBox(Bottom(text), HSpacing(0.5), Bottom()) end |
- (Object) WriteDialog
Write settings dialog
52 53 54 55 |
# File '../../src/include/tftp-server/dialogs.rb', line 52 def WriteDialog ret = TftpServer.Write ret ? :next : :abort end |