ftp_paradise 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +319 -0
  3. data/bin/create_remote_directory +9 -0
  4. data/bin/ftp_get +17 -0
  5. data/bin/ftp_gtk3 +7 -0
  6. data/bin/ftp_upload +42 -0
  7. data/bin/ftp_upload_binary +18 -0
  8. data/bin/iftp +7 -0
  9. data/bin/remote_remove +28 -0
  10. data/doc/README.gen +302 -0
  11. data/doc/todo/TODO_FOR_FTP_PARADISE_PROJECT.md +79 -0
  12. data/ftp_paradise.gemspec +122 -0
  13. data/lib/ftp_paradise.rb +5 -0
  14. data/lib/ftp_paradise/base/cliner.rb +23 -0
  15. data/lib/ftp_paradise/base/colours.rb +83 -0
  16. data/lib/ftp_paradise/base/prototype.rb +171 -0
  17. data/lib/ftp_paradise/base/reset.rb +29 -0
  18. data/lib/ftp_paradise/colours/colours.rb +141 -0
  19. data/lib/ftp_paradise/colours/use_colours.rb +76 -0
  20. data/lib/ftp_paradise/configuration/configuration.rb +49 -0
  21. data/lib/ftp_paradise/connection/README.md +1 -0
  22. data/lib/ftp_paradise/connection/connection.rb +35 -0
  23. data/lib/ftp_paradise/connection/constants.rb +46 -0
  24. data/lib/ftp_paradise/connection/data.rb +164 -0
  25. data/lib/ftp_paradise/connection/debug.rb +78 -0
  26. data/lib/ftp_paradise/connection/directory_handling.rb +271 -0
  27. data/lib/ftp_paradise/connection/do_login.rb +108 -0
  28. data/lib/ftp_paradise/connection/download.rb +86 -0
  29. data/lib/ftp_paradise/connection/file_handling.rb +174 -0
  30. data/lib/ftp_paradise/connection/ftp_object.rb +21 -0
  31. data/lib/ftp_paradise/connection/initialize.rb +88 -0
  32. data/lib/ftp_paradise/connection/initialize_a_new_net_ftp_object_with_this_url.rb +20 -0
  33. data/lib/ftp_paradise/connection/is_connected.rb +46 -0
  34. data/lib/ftp_paradise/connection/misc.rb +474 -0
  35. data/lib/ftp_paradise/connection/notify.rb +71 -0
  36. data/lib/ftp_paradise/connection/password.rb +47 -0
  37. data/lib/ftp_paradise/connection/port.rb +33 -0
  38. data/lib/ftp_paradise/connection/remote_pwd.rb +72 -0
  39. data/lib/ftp_paradise/connection/remote_url.rb +164 -0
  40. data/lib/ftp_paradise/connection/remove.rb +143 -0
  41. data/lib/ftp_paradise/connection/reset.rb +78 -0
  42. data/lib/ftp_paradise/connection/run.rb +18 -0
  43. data/lib/ftp_paradise/connection/set_array_available_hosts.rb +27 -0
  44. data/lib/ftp_paradise/connection/set_input.rb +18 -0
  45. data/lib/ftp_paradise/connection/show.rb +153 -0
  46. data/lib/ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb +24 -0
  47. data/lib/ftp_paradise/connection/transfer_mode.rb +163 -0
  48. data/lib/ftp_paradise/connection/upload.rb +253 -0
  49. data/lib/ftp_paradise/connection/use_default_dataset.rb +40 -0
  50. data/lib/ftp_paradise/connection/username.rb +42 -0
  51. data/lib/ftp_paradise/constants/constants.rb +19 -0
  52. data/lib/ftp_paradise/constants/misc.rb +57 -0
  53. data/lib/ftp_paradise/constants/namespace.rb +14 -0
  54. data/lib/ftp_paradise/constants/newline.rb +14 -0
  55. data/lib/ftp_paradise/constants/roebe.rb +31 -0
  56. data/lib/ftp_paradise/constants/roebe_ftp_constants.rb +233 -0
  57. data/lib/ftp_paradise/entry/entry.rb +300 -0
  58. data/lib/ftp_paradise/gui/gtk2/ftp_paradise.rb +34 -0
  59. data/lib/ftp_paradise/gui/gtk3/ftp_paradise.rb +34 -0
  60. data/lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb +709 -0
  61. data/lib/ftp_paradise/images/connection_image.png +0 -0
  62. data/lib/ftp_paradise/interactive_ftp/constants.rb +103 -0
  63. data/lib/ftp_paradise/interactive_ftp/directory_handling.rb +216 -0
  64. data/lib/ftp_paradise/interactive_ftp/help.rb +50 -0
  65. data/lib/ftp_paradise/interactive_ftp/initialize.rb +27 -0
  66. data/lib/ftp_paradise/interactive_ftp/interactive_ftp.rb +998 -0
  67. data/lib/ftp_paradise/interactive_ftp/main_loop.rb +51 -0
  68. data/lib/ftp_paradise/interactive_ftp/menu.rb +786 -0
  69. data/lib/ftp_paradise/interactive_ftp/misc.rb +208 -0
  70. data/lib/ftp_paradise/interactive_ftp/mode.rb +124 -0
  71. data/lib/ftp_paradise/interactive_ftp/readline.rb +113 -0
  72. data/lib/ftp_paradise/interactive_ftp/remove.rb +97 -0
  73. data/lib/ftp_paradise/interactive_ftp/reset.rb +90 -0
  74. data/lib/ftp_paradise/interactive_ftp/run.rb +22 -0
  75. data/lib/ftp_paradise/interactive_ftp/show.rb +184 -0
  76. data/lib/ftp_paradise/interactive_ftp/upload.rb +90 -0
  77. data/lib/ftp_paradise/interactive_ftp/user_input.rb +53 -0
  78. data/lib/ftp_paradise/project/project.rb +64 -0
  79. data/lib/ftp_paradise/requires/common_basic_requires.rb +14 -0
  80. data/lib/ftp_paradise/requires/common_external_requires.rb +9 -0
  81. data/lib/ftp_paradise/requires/require_the_constants.rb +7 -0
  82. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project.rb +18 -0
  83. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project_with_the_GUI_bindings.rb +10 -0
  84. data/lib/ftp_paradise/requires/require_the_toplevel_methods.rb +24 -0
  85. data/lib/ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb +28 -0
  86. data/lib/ftp_paradise/toplevel_methods/clear_user_dataset.rb +28 -0
  87. data/lib/ftp_paradise/toplevel_methods/connect.rb +50 -0
  88. data/lib/ftp_paradise/toplevel_methods/data.rb +31 -0
  89. data/lib/ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb +37 -0
  90. data/lib/ftp_paradise/toplevel_methods/directory_related_actions.rb +33 -0
  91. data/lib/ftp_paradise/toplevel_methods/e.rb +16 -0
  92. data/lib/ftp_paradise/toplevel_methods/file_related_actions.rb +49 -0
  93. data/lib/ftp_paradise/toplevel_methods/ftp_object.rb +270 -0
  94. data/lib/ftp_paradise/toplevel_methods/is_on_roebe.rb +20 -0
  95. data/lib/ftp_paradise/toplevel_methods/login_name.rb +49 -0
  96. data/lib/ftp_paradise/toplevel_methods/misc.rb +16 -0
  97. data/lib/ftp_paradise/toplevel_methods/opn.rb +24 -0
  98. data/lib/ftp_paradise/toplevel_methods/password.rb +50 -0
  99. data/lib/ftp_paradise/toplevel_methods/port.rb +41 -0
  100. data/lib/ftp_paradise/toplevel_methods/rds.rb +18 -0
  101. data/lib/ftp_paradise/toplevel_methods/remote_url.rb +57 -0
  102. data/lib/ftp_paradise/toplevel_methods/time.rb +45 -0
  103. data/lib/ftp_paradise/toplevel_methods/upload_and_download.rb +108 -0
  104. data/lib/ftp_paradise/version/version.rb +19 -0
  105. data/lib/ftp_paradise/www/public/css/style.css +3 -0
  106. data/lib/ftp_paradise/www/sinatra_web_interface.rb +242 -0
  107. data/lib/ftp_paradise/www/views/index.slim +3 -0
  108. data/lib/ftp_paradise/www/views/layout.slim +11 -0
  109. data/lib/ftp_paradise/www/web_interface.cgi +34 -0
  110. data/lib/ftp_paradise/yaml/automatically_connect_on_startup_of_the_interactive_ftp_shell.yml +1 -0
  111. data/lib/ftp_paradise/yaml/debug.yml +1 -0
  112. data/lib/ftp_paradise/yaml/open_in_default_editor.yml +1 -0
  113. data/lib/ftp_paradise/yaml/show_full_names.yml +1 -0
  114. data/lib/ftp_paradise/yaml/use_colours.yml +1 -0
  115. data/test/testing_ftp_paradise.rb +94 -0
  116. data/test/testing_minimal_pure_net_ftp_example_to_connect.rb +28 -0
  117. data/test/testing_the_ftp_connection_component.rb +70 -0
  118. data/test/testing_upload_a_local_directory.rb +10 -0
  119. metadata +336 -0
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === FtpParadise::GUI::Gtk::FtpParadise
6
+ # =========================================================================== #
7
+ # require 'ftp_paradise/gui/gtk2/ftp_paradise.rb'
8
+ # FtpParadise::GUI::Gtk::FtpParadise.run
9
+ # =========================================================================== #
10
+ require 'gtk_paradise/require_gtk2'
11
+
12
+ module FtpParadise
13
+
14
+ module GUI
15
+
16
+ module Gtk
17
+
18
+ class FtpParadise < ::Gtk::Box
19
+
20
+ require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb'
21
+ include ::FtpParadise::GUI::Gtk::FtpParadiseModule
22
+
23
+ # ========================================================================= #
24
+ # === FtpParadise::GUI::Gtk::FtpParadise.run
25
+ # ========================================================================= #
26
+ def self.run
27
+ ::FtpParadise::GUI::Gtk::FtpParadiseModule.run
28
+ end
29
+
30
+ end; end; end; end
31
+
32
+ if __FILE__ == $PROGRAM_NAME
33
+ FtpParadise::GUI::Gtk::FtpParadise.run
34
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === FtpParadise::GUI::Gtk::FtpParadise
6
+ # =========================================================================== #
7
+ # require 'ftp_paradise/gui/gtk3/ftp_paradise.rb'
8
+ # FtpParadise::GUI::Gtk::FtpParadise.run
9
+ # =========================================================================== #
10
+ require 'gtk_paradise/require_gtk3'
11
+
12
+ module FtpParadise
13
+
14
+ module GUI
15
+
16
+ module Gtk
17
+
18
+ class FtpParadise < ::Gtk::Box
19
+
20
+ require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb'
21
+ include ::FtpParadise::GUI::Gtk::FtpParadiseModule
22
+
23
+ # ========================================================================= #
24
+ # === FtpParadise::GUI::Gtk::FtpParadise.run
25
+ # ========================================================================= #
26
+ def self.run
27
+ ::FtpParadise::GUI::Gtk::FtpParadiseModule.run
28
+ end
29
+
30
+ end; end; end; end
31
+
32
+ if __FILE__ == $PROGRAM_NAME
33
+ FtpParadise::GUI::Gtk::FtpParadise.run
34
+ end
@@ -0,0 +1,709 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === FtpParadise::GUI::Gtk::FtpParadiseModule
6
+ #
7
+ # The purpose of this class is to provide a GTK-FTP Client, loosely
8
+ # modelled after the client called "gftp".
9
+ # =========================================================================== #
10
+ # require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb'
11
+ # include ::FtpParadise::GUI::Gtk::FtpParadiseModule
12
+ # =========================================================================== #
13
+ module FtpParadise
14
+
15
+ module GUI
16
+
17
+ module Gtk
18
+
19
+ module FtpParadiseModule
20
+
21
+ require 'ftp_paradise/base/prototype.rb'
22
+ include ::FtpParadise::Base
23
+
24
+ require 'net/ftp'
25
+
26
+ require 'ftp_paradise/project/project.rb'
27
+
28
+ require 'ftp_paradise/constants/roebe_ftp_constants.rb'
29
+
30
+ require 'gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb'
31
+
32
+ require 'gtk_paradise/requires/require_the_base_module.rb'
33
+ include ::Gtk::BaseModule
34
+
35
+ # ========================================================================= #
36
+ # === NAMESPACE
37
+ # ========================================================================= #
38
+ NAMESPACE = inspect
39
+
40
+ # ========================================================================= #
41
+ # === TITLE
42
+ # ========================================================================= #
43
+ TITLE = 'FTP Client'
44
+
45
+ # ========================================================================= #
46
+ # === WIDTH
47
+ # ========================================================================= #
48
+ WIDTH = 1600
49
+
50
+ # ========================================================================= #
51
+ # === HEIGHT
52
+ # ========================================================================= #
53
+ HEIGHT = 800
54
+
55
+ # ========================================================================= #
56
+ # === FTP_MAIN_ICON
57
+ # ========================================================================= #
58
+ FTP_MAIN_ICON = HOME_DIRECTORY_OF_USER_X+'DATA/images/PC/FTP/FTP.png'
59
+
60
+ # ========================================================================= #
61
+ # === SHALL_WE_DEBUG
62
+ # ========================================================================= #
63
+ SHALL_WE_DEBUG = false
64
+
65
+ # ========================================================================= #
66
+ # === MAIN_BG_COLOUR
67
+ # ========================================================================= #
68
+ MAIN_BG_COLOUR = :beige
69
+
70
+ # ========================================================================= #
71
+ # === MAIN_BG_COLOUR_PRELIGHT
72
+ # ========================================================================= #
73
+ MAIN_BG_COLOUR_PRELIGHT = :blanchedalmond
74
+
75
+ # ========================================================================= #
76
+ # === DEFAULT_USERNAME
77
+ # ========================================================================= #
78
+ DEFAULT_USERNAME = 'podi_278950456'
79
+
80
+ # ========================================================================= #
81
+ # === DEFAULT_REMOTE_HOST
82
+ # ========================================================================= #
83
+ DEFAULT_REMOTE_HOST = 'ftpupload.net'
84
+
85
+ # ========================================================================= #
86
+ # === DEFAULT_PASSWORD
87
+ # ========================================================================= #
88
+ DEFAULT_PASSWORD = '1aaaaaa'
89
+
90
+ # ========================================================================= #
91
+ # === DEFAULT_REMOTE_PORT
92
+ # ========================================================================= #
93
+ DEFAULT_REMOTE_PORT = 21
94
+
95
+ # ========================================================================= #
96
+ # === YES_THE_USER_IS_CONNECTED
97
+ # ========================================================================= #
98
+ YES_THE_USER_IS_CONNECTED = 'Yes!'
99
+
100
+ # ========================================================================= #
101
+ # === MY_TEMP
102
+ # ========================================================================= #
103
+ if ENV['MY_TEMP']
104
+ MY_TEMP = ENV['MY_TEMP'].to_s+'/'
105
+ elsif File.directory?('/home/Temp/')
106
+ MY_TEMP = '/home/Temp/'
107
+ else
108
+ MY_TEMP = '/tmp/'
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === initialize
113
+ # ========================================================================= #
114
+ def initialize(
115
+ run_already = true
116
+ )
117
+ super(:vertical)
118
+ reset
119
+ run if run_already
120
+ end
121
+
122
+ # ========================================================================= #
123
+ # === reset (reset tag)
124
+ # ========================================================================= #
125
+ def reset
126
+ reset_the_internal_variables
127
+ # ======================================================================= #
128
+ # === @configuration
129
+ # ======================================================================= #
130
+ @configuration = [true, __dir__, NAMESPACE]
131
+ # ======================================================================= #
132
+ # === @title
133
+ # ======================================================================= #
134
+ @title = TITLE
135
+ # ======================================================================= #
136
+ # === @width
137
+ # ======================================================================= #
138
+ @width = WIDTH
139
+ # ======================================================================= #
140
+ # === @height
141
+ # ======================================================================= #
142
+ @height = HEIGHT
143
+ # ======================================================================= #
144
+ # === @ftp_connection
145
+ # ======================================================================= #
146
+ @ftp_connection = nil
147
+ # ======================================================================= #
148
+ # === @debug
149
+ # ======================================================================= #
150
+ @debug = SHALL_WE_DEBUG
151
+ # ======================================================================= #
152
+ # === @hash_user_data
153
+ # ======================================================================= #
154
+ if is_on_roebe?
155
+ # ===================================================================== #
156
+ # This is valid for my home-system.
157
+ # ===================================================================== #
158
+ @hash_user_data = ::FtpParadise::RoebeFtpConstants.hash_ftp_dataset?['podserver']
159
+ else
160
+ # ===================================================================== #
161
+ # Else we simply build up some default values; the regular user
162
+ # has to overrule them anyway, via the GUI.
163
+ # ===================================================================== #
164
+ @hash_user_data = {}
165
+ @hash_user_data['user_name'] = DEFAULT_USERNAME
166
+ @hash_user_data['password'] = DEFAULT_PASSWORD
167
+ @hash_user_data['url'] = DEFAULT_REMOTE_HOST
168
+ @hash_user_data['port'] = DEFAULT_REMOTE_PORT
169
+ end
170
+ initialize_the_connection_image
171
+ set_use_this_font(:dejavu_condensed_21)
172
+ use_gtk_paradise_project_css_file
173
+ infer_the_size_automatically
174
+ end
175
+
176
+ # ========================================================================= #
177
+ # === initialize_the_connection_image
178
+ # ========================================================================= #
179
+ def initialize_the_connection_image
180
+ # ======================================================================= #
181
+ # === @connection_image
182
+ # ======================================================================= #
183
+ @connection_image = gtk_image(
184
+ ::FtpParadise.project_base_dir?+'images/connection_image.png'
185
+ )
186
+ @connection_image.css_class('bblack1')
187
+ end
188
+
189
+ # ========================================================================= #
190
+ # === padding?
191
+ # ========================================================================= #
192
+ def padding?
193
+ 2
194
+ end
195
+
196
+ # ========================================================================= #
197
+ # === border_size?
198
+ # ========================================================================= #
199
+ def border_size?
200
+ 2
201
+ end
202
+
203
+ # ========================================================================= #
204
+ # === create_button_delete_remote_file
205
+ # ========================================================================= #
206
+ def create_button_delete_remote_file
207
+ @button_delete_remote_file = gtk_button('Delete remote file')
208
+ @button_delete_remote_file.fancy_tooltips =
209
+ 'Use this when you wish to remove a remote file.'
210
+ @button_delete_remote_file.on_clicked {
211
+ do_delete_remote_file
212
+ }
213
+ end
214
+
215
+ # ========================================================================= #
216
+ # === create_skeleton (create tag)
217
+ # ========================================================================= #
218
+ def create_skeleton
219
+ create_debug_button
220
+ create_button_delete_remote_file
221
+ create_status_icon
222
+ create_statusbar
223
+ @grid_user_data = gtk_grid
224
+ @grid_user_data.set_column_spacing(5)
225
+ @grid_user_data.set_row_spacing(5)
226
+ @grid_user_data.set_size_request(300, 50)
227
+ @grid_user_data.set_border_width(20)
228
+ # ======================================================================= #
229
+ # Populate the grid next.
230
+ # ======================================================================= #
231
+ @grid_user_data.set_left(
232
+ text('Username:')
233
+ )
234
+ @entry_username = gtk_entry
235
+ @entry_username.set_size_request(300, 50)
236
+ @entry_username.set_text(@hash_user_data['user_name'])
237
+ @entry_username.deselect
238
+ @entry_username.css_class('pad8px')
239
+ @grid_user_data.set_right(@entry_username)
240
+
241
+ # ======================================================================= #
242
+ # === The user Password
243
+ # ======================================================================= #
244
+ @grid_user_data.set_left(
245
+ text('Password:')
246
+ )
247
+ @entry_user_password = gtk_entry
248
+ @entry_user_password.set_size_request(300, 50)
249
+ @entry_user_password.set_text(@hash_user_data['password'])
250
+ @entry_user_password.deselect
251
+ @entry_user_password.css_class('pad8px')
252
+ @grid_user_data.set_right(@entry_user_password)
253
+
254
+ # ======================================================================= #
255
+ # === Remote host:
256
+ # ======================================================================= #
257
+ @grid_user_data.set_left(
258
+ text('Remote host:')
259
+ )
260
+ @entry_remote_host = gtk_entry
261
+ @entry_remote_host.set_size_request(300, 50)
262
+ @entry_remote_host.set_text(@hash_user_data['url'])
263
+ @entry_remote_host.css_class('pad8px')
264
+ @grid_user_data.set_right(
265
+ @entry_remote_host
266
+ )
267
+ @grid_user_data.set_left(
268
+ text('Port:')
269
+ )
270
+ @entry_port = gtk_entry
271
+ @entry_port.set_size_request(300, 50)
272
+ @entry_port.set_text(@hash_user_data['port'].to_s)
273
+ @entry_port.css_class('pad8px')
274
+ @grid_user_data.set_right(
275
+ @entry_port
276
+ )
277
+
278
+ @frame_for_the_grid_user_data = gtk_frame
279
+ @frame_for_the_grid_user_data.set_text(
280
+ ' User data for the FTP connection '
281
+ )
282
+ @frame_for_the_grid_user_data.add(@grid_user_data)
283
+ @frame_for_the_grid_user_data.css_class('pad8px')
284
+ @frame_for_the_grid_user_data.set_border_width(2)
285
+ @frame_for_the_grid_user_data.set_size_request(400, 40)
286
+ end
287
+
288
+ # ========================================================================= #
289
+ # === connect_skeleton (connect tag)
290
+ # ========================================================================= #
291
+ def connect_skeleton
292
+ abort_on_exception
293
+ hbox = gtk_hbox
294
+ hbox.minimal(@frame_for_the_grid_user_data, 5)
295
+ # ======================================================================= #
296
+ # === widget2
297
+ # ======================================================================= #
298
+ vbox_is_the_user_connected = gtk_vbox
299
+ vbox_is_the_user_connected.set_border_width(10)
300
+ event_box_for_the_connection_image = gtk_event_box(@connection_image)
301
+ event_box_for_the_connection_image.fancy_tooltips =
302
+ 'Click on this image to connect to the specified, remote host.'
303
+ event_box_for_the_connection_image.on_clicked {
304
+ do_connect_to_the_remote_host_specified
305
+ }
306
+ event_box_for_the_connection_image.set_size_request(50, 50)
307
+ vbox_is_the_user_connected.minimal(event_box_for_the_connection_image)
308
+ @label_are_we_connected = text('No')
309
+ vbox_is_the_user_connected.add(@label_are_we_connected)
310
+ frame_is_the_user_connected = gtk_frame
311
+ frame_is_the_user_connected.set_text(' Is the user connected: ')
312
+ frame_is_the_user_connected.add(vbox_is_the_user_connected)
313
+
314
+ # ======================================================================= #
315
+ # Next add the box for the "Actions to perform".
316
+ # ======================================================================= #
317
+ frame_action_to_perform = gtk_frame
318
+ frame_action_to_perform.set_text(' Action to perform: ')
319
+ frame_action_to_perform.label_widget.fancy_tooltips =
320
+ 'Denote via this widget which action is to be performed.'
321
+ vbox_action_to_perform = gtk_vbox
322
+ vbox_action_to_perform.set_border_width(10)
323
+ @button_upload = button('Upload')
324
+ @button_upload.fancy_tooltips =
325
+ '<b>Upload</b> the selected local file to the remote host.'
326
+ @button_upload.on_clicked {
327
+ do_upload_the_selected_file
328
+ }
329
+ vbox_action_to_perform.add(@button_upload)
330
+ @button_download = button('Download')
331
+ @button_download.fancy_tooltips =
332
+ '<b>Download</b> the selected (<b>remote</b>) files/directories.'
333
+ @button_download.on_clicked {
334
+ do_download_the_remote_file_or_directory
335
+ }
336
+ vbox_action_to_perform.add(@button_download)
337
+ vbox_action_to_perform.add(@button_delete_remote_file)
338
+ vbox_action_to_perform.add(@button_debug)
339
+ frame_action_to_perform.add(vbox_action_to_perform)
340
+
341
+ draggable_widget_between_two_frames = draggable_up_and_down_pane(
342
+ frame_is_the_user_connected,
343
+ frame_action_to_perform
344
+ )
345
+ # hbox << frame_is_the_user_connected
346
+ # hbox << frame_action_to_perform
347
+ hbox.add(draggable_widget_between_two_frames)
348
+
349
+ minimal(hbox, 2)
350
+ hbox_with_the_two_file_listing_widgets = gtk_hbox
351
+ vbox1 = gtk_vbox
352
+ vbox1 << text('Local directory')
353
+ @entry_local_directory = gtk_entry
354
+ if File.directory? MY_TEMP
355
+ @entry_local_directory.set_text(MY_TEMP)
356
+ else
357
+ @entry_local_directory.set_text(return_pwd)
358
+ end
359
+ @entry_local_directory.set_font(:hack_15)
360
+ vbox1 << @entry_local_directory
361
+ # ======================================================================= #
362
+ # === @directory_content_widget1
363
+ # ======================================================================= #
364
+ @directory_content_widget1 = ::Gtk::DirectoryContentWidget.new {
365
+ :do_not_use_widget_allowing_the_user_to_change_the_local_directory
366
+ }
367
+ @directory_content_widget1.set_start_dir(@entry_local_directory.text?)
368
+ @directory_content_widget1.set_font(:hack_18)
369
+ @entry_local_directory.on_enter {
370
+ target = @entry_local_directory.text?
371
+ if File.directory? target
372
+ Dir.chdir(target)
373
+ end
374
+ @directory_content_widget1.set_use_this_directory(
375
+ target
376
+ )
377
+ @directory_content_widget1.update
378
+ }
379
+ vbox1.maximal(@directory_content_widget1, 5)
380
+ # Right right middle-vbox:
381
+ vbox2 = gtk_vbox
382
+ vbox2 << text('Remote directory')
383
+ @directory_content_widget2 = ::Gtk::DirectoryContentWidget.new {
384
+ :do_not_use_widget_allowing_the_user_to_change_the_local_directory
385
+ }
386
+ # ======================================================================= #
387
+ # === @directory_content_widget2
388
+ # ======================================================================= #
389
+ @directory_content_widget2.set_font(:hack_18)
390
+ @directory_content_widget2.clear # This widget is empty on startup.
391
+ @entry_remote_directory = gtk_entry
392
+ @entry_remote_directory.set_font(:hack_15)
393
+ vbox2 << @entry_remote_directory
394
+ vbox2 << @directory_content_widget2
395
+ # ======================================================================= #
396
+ # Next add vbox1 and vbox2 together.
397
+ # ======================================================================= #
398
+ up_and_down_spacer = up_and_down_pane(vbox1, vbox2)
399
+ up_and_down_spacer.position = 780
400
+ hbox_with_the_two_file_listing_widgets.maximal(up_and_down_spacer)
401
+ minimal(hbox_with_the_two_file_listing_widgets, 2)
402
+ do_style_all_buttons_in_a_uniform_manner
403
+ end
404
+
405
+ # ========================================================================= #
406
+ # === user_password?
407
+ # ========================================================================= #
408
+ def user_password?
409
+ @entry_user_password.text?
410
+ end
411
+
412
+ # ========================================================================= #
413
+ # === remote_url?
414
+ # ========================================================================= #
415
+ def remote_url?
416
+ @entry_remote_host.text?
417
+ end
418
+
419
+ # ========================================================================= #
420
+ # === set_remove_directory
421
+ # ========================================================================= #
422
+ def set_remote_directory(i = '/')
423
+ @entry_remote_directory.set_text(i.to_s)
424
+ end
425
+
426
+ # ========================================================================= #
427
+ # === GtkParadise::GUI::Gtk::FtpParadiseModule.run
428
+ # ========================================================================= #
429
+ def self.run(
430
+ i = ARGV
431
+ )
432
+ require 'gtk_paradise/run'
433
+ _ = ::FtpParadise::GUI::Gtk::FtpParadise.new(i)
434
+ r = ::Gtk.run
435
+ r << _
436
+ r.set_size_request(_.width?, _.height?)
437
+ r.automatic_title
438
+ r.top_left_then_run
439
+ end
440
+
441
+ # ========================================================================= #
442
+ # === clear_right_listing
443
+ # ========================================================================= #
444
+ def clear_right_listing
445
+ @directory_content_widget2.clear
446
+ end
447
+
448
+ # ========================================================================= #
449
+ # === are_we_connected?
450
+ # ========================================================================= #
451
+ def are_we_connected?
452
+ @label_are_we_connected.text? == YES_THE_USER_IS_CONNECTED
453
+ end
454
+
455
+ # ========================================================================= #
456
+ # === do_download_the_remote_file_or_directory
457
+ # ========================================================================= #
458
+ def do_download_the_remote_file_or_directory(
459
+ this_file = @directory_content_widget2.selected?
460
+ )
461
+ if are_we_connected?
462
+ # ===================================================================== #
463
+ # In this case we can proceed to download the remote file. We have
464
+ # to make sure the remote file exists, though.
465
+ # ===================================================================== #
466
+ begin
467
+ ::FtpParadise.download(
468
+ this_file,
469
+ @ftp_connection
470
+ )
471
+ rescue Exception => error
472
+ e 'The file '+this_file.to_s+' does not exist, though.'
473
+ pp error.class
474
+ pp error
475
+ end
476
+ else
477
+ e 'But there is no active FTP connection right now.'
478
+ end
479
+ end
480
+
481
+ # ========================================================================= #
482
+ # === is_on_roebe?
483
+ # ========================================================================= #
484
+ def is_on_roebe?
485
+ ::FtpParadise.is_on_roebe?
486
+ end
487
+
488
+ # ========================================================================= #
489
+ # === do_connect_to_the_remote_host_specified
490
+ #
491
+ # This is the method that will connect to the remove host specified.
492
+ # ========================================================================= #
493
+ def do_connect_to_the_remote_host_specified(
494
+ remote_url = remote_url?
495
+ )
496
+ @ftp_connection = Net::FTP.open(remote_url)
497
+ # @ftp_connection.passive = true
498
+ user_name = user_name?
499
+ user_password = user_password?
500
+ @ftp_connection.login(user_name, user_password)
501
+ entries = @ftp_connection.list('*')
502
+ @label_are_we_connected.set_text(YES_THE_USER_IS_CONNECTED)
503
+ clear_right_listing
504
+ set_remote_directory('/')
505
+ modified_entries = entries.map {|line|
506
+ if line.empty? or line.end_with?('.')
507
+ line = nil
508
+ end
509
+ if line and line.end_with? ':'
510
+ line = line.dup
511
+ line.chop!
512
+ line << '/'
513
+ end
514
+ line
515
+ }.compact
516
+ modified_entries = modified_entries.map! {|line|
517
+ splitted = line.split(' ')
518
+ filename = splitted.last
519
+ type = 'dir or file here' # Default.
520
+ if line.end_with? '/'
521
+ type = 'directory'
522
+ end
523
+ [filename, type,'LAST_MODIFIED_GOES_IN_HERE']
524
+ }
525
+ @directory_content_widget2.feed_this_data(modified_entries)
526
+ end; alias do_connect do_connect_to_the_remote_host_specified # === do_connect
527
+
528
+ # ========================================================================= #
529
+ # === debug?
530
+ # ========================================================================= #
531
+ def debug?
532
+ @debug
533
+ end
534
+
535
+ # ========================================================================= #
536
+ # === run (run tag)
537
+ # ========================================================================= #
538
+ def run
539
+ create_skeleton_then_connect_skeleton
540
+ do_connect if is_on_roebe? # Connect at once on my home system.
541
+ end
542
+
543
+ # ========================================================================= #
544
+ # === do_style_all_buttons_in_a_uniform_manner
545
+ # ========================================================================= #
546
+ def do_style_all_buttons_in_a_uniform_manner
547
+ return_all_buttons.each {|this_button|
548
+ this_button.modify_background(:active, MAIN_BG_COLOUR )
549
+ this_button.modify_background(:normal, MAIN_BG_COLOUR )
550
+ this_button.modify_background(:prelight, MAIN_BG_COLOUR_PRELIGHT)
551
+ this_button.set_border_width(1)
552
+ this_button.bblack1
553
+ }
554
+ end
555
+
556
+ # ========================================================================= #
557
+ # === add_status_message
558
+ #
559
+ # Use this to append to the Statusbar.
560
+ # ========================================================================= #
561
+ def add_status_message(i)
562
+ @status_bar.push(@status_bar_context_id, i)
563
+ end
564
+
565
+ # ========================================================================= #
566
+ # === create_status_icon
567
+ # ========================================================================= #
568
+ def create_status_icon
569
+ @status_icon = gtk_status_icon
570
+ if File.exist? FTP_MAIN_ICON
571
+ @status_icon.pixbuf = GdkPixbuf::Pixbuf.new(file: FTP_MAIN_ICON)
572
+ end
573
+ @status_icon.fancy_tooltips = 'StatusIcon'
574
+ end
575
+
576
+ # ========================================================================= #
577
+ # === create_statusbar
578
+ #
579
+ # Create the Statusbar.
580
+ # ========================================================================= #
581
+ def create_statusbar
582
+ @status_bar = gtk_statusbar
583
+ if @status_bar.respond_to?(:has_resize_grip=)
584
+ @status_bar.has_resize_grip = true
585
+ end
586
+ @status_bar_context_id = @status_bar.get_context_id('Gtk Ftp Client')
587
+ end
588
+
589
+ # ========================================================================= #
590
+ # === create_debug_button (debug tag, debug button)
591
+ # ========================================================================= #
592
+ def create_debug_button
593
+ @button_debug = gtk_button('_Debug') # The debug-button.
594
+ @button_debug.on_clicked {
595
+ e 'Debugging FTP Client.'
596
+ ecomment ('The password is: ').ljust(20)+password?
597
+ ecomment 'The login name is: '+username?, token: ':'
598
+ }
599
+ end
600
+
601
+ # ========================================================================= #
602
+ # === user_name?
603
+ # ========================================================================= #
604
+ def user_name?
605
+ @entry_username.text?
606
+ end; alias username? user_name? # === username?
607
+
608
+ # ========================================================================= #
609
+ # === do_delete_remote_file
610
+ #
611
+ # Wrapper to delete a remote file.
612
+ # ========================================================================= #
613
+ def do_delete_remote_file
614
+ ewarn 'Deleting this remote file:'
615
+ efancy selection?(:right)
616
+ @ftp_connection.remove_file( selection?(:right) )
617
+ update_everything
618
+ end
619
+
620
+ # ========================================================================= #
621
+ # === output_coloured_line
622
+ #
623
+ # Makes a nicely coloured line.
624
+ # ========================================================================= #
625
+ def output_coloured_line(
626
+ input, optional_colour = 'yelb'
627
+ )
628
+ cliner {
629
+ e sfancy(input)
630
+ }
631
+ end
632
+
633
+ # ========================================================================= #
634
+ # === return_default_user_name_based_on_selected_host
635
+ # ========================================================================= #
636
+ def return_default_user_name_based_on_selected_host(
637
+ selected_host = host?
638
+ )
639
+ selected_host = FtpParadise::RoebeFtpConstants.
640
+ return_user_name_based_on_given_host(selected_host)
641
+ return selected_host
642
+ end
643
+
644
+ # ========================================================================= #
645
+ # === connect_to_remote_host
646
+ #
647
+ # Use this method when connecting to the remote host.
648
+ # ========================================================================= #
649
+ def connect_to_remote_host(this_host = host?)
650
+ this_host = this_host.to_s
651
+ @ftp_connection.connect_to(this_host, :be_verbose)
652
+ add_status_message 'Connecting to '+this_host.to_s+' now.'
653
+ try_to_sync_label_remote_dir
654
+ end
655
+
656
+ # ========================================================================= #
657
+ # === do_upload_the_selected_file
658
+ # ========================================================================= #
659
+ def do_upload_the_selected_file
660
+ _ = left_tree_view?.selection?
661
+ if _
662
+ ::FtpParadise.upload(_, :short_variant, @ftp_connection)
663
+ else
664
+ e 'Nothing was selected.'
665
+ end
666
+ end
667
+
668
+ # ========================================================================= #
669
+ # === left_tree_view?
670
+ # ========================================================================= #
671
+ def left_tree_view?
672
+ @directory_content_widget1
673
+ end
674
+
675
+ end; end; end
676
+
677
+ # =========================================================================== #
678
+ # === FtpParadise.do_start_gui
679
+ #
680
+ # This will output what will be done, then start the GUI bindings.
681
+ #
682
+ # This method can be invoked via:
683
+ #
684
+ # ftpparadise --gui
685
+ #
686
+ # =========================================================================== #
687
+ def self.do_start_gui
688
+ opnn; puts 'We will next start the GUI.'
689
+ FtpParadise::GUI::Gtk::FtpParadiseModule.start_gtk
690
+ end
691
+
692
+ # =========================================================================== #
693
+ # === FtpParadise.start_gtk
694
+ # =========================================================================== #
695
+ def self.start_gtk
696
+ FtpParadise::GUI::Gtk::FtpParadiseModule.run
697
+ end
698
+
699
+ # =========================================================================== #
700
+ # === FtpParadise.gtk_widget
701
+ #
702
+ # This method will return a useable GTK widget that can be embedded into
703
+ # other applications.
704
+ # =========================================================================== #
705
+ def self.gtk_widget
706
+ FtpParadise::GUI::Gtk::FtpParadiseModule
707
+ end
708
+
709
+ end