Webdar 1.0.0
Web user interface to libdar
saisie.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef SAISIE_HPP
25#define SAISIE_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <dar/libdar.hpp>
36
37 // webdar headers
38#include "html_page.hpp"
39#include "html_menu.hpp"
40#include "html_aiguille.hpp"
41#include "html_div.hpp"
42#include "events.hpp"
43#include "html_yes_no_box.hpp"
44#include "html_options_read.hpp"
45#include "html_options_test.hpp"
46#include "html_archive_read.hpp"
47#include "html_archive_extract.hpp"
48#include "html_archive_create.hpp"
49#include "html_archive_isolate.hpp"
50#include "html_archive_merge.hpp"
51#include "html_archive_repair.hpp"
52#include "html_archive_compare.hpp"
53#include "html_double_button.hpp"
54#include "html_double_button.hpp"
55#include "html_derouleur.hpp"
56#include "html_demo.hpp"
57#include "html_disconnect.hpp"
58#include "html_options_list.hpp"
59#include "bibliotheque.hpp"
60#include "html_bibliotheque.hpp"
61#include "html_fichier.hpp"
62#include "html_image.hpp"
63
65
83
84
105class saisie : public html_page, public actor, public events
106{
107public:
109 static const std::string event_closing;
110 static const std::string event_restore;
111 static const std::string event_compare;
112 static const std::string event_test;
113 static const std::string event_list;
114 static const std::string event_summary;
115 static const std::string event_create;
116 static const std::string event_isolate;
117 static const std::string event_merge;
118 static const std::string event_repair;
119 static const std::string changed_session_name;
120 static const std::string event_disconn;
121 static const std::string event_download;
122
124 saisie();
125 saisie(const saisie & ref) = delete;
126 saisie(saisie && ref) noexcept = delete;
127 saisie & operator = (const saisie & ref) = delete;
128 saisie & operator = (saisie && ref) noexcept = delete;
129 ~saisie() = default;
130
132 virtual void on_event(const std::string & event_name) override;
133
134
135 // list of field available to run libdar
136
137 // reading parameters
138 std::string get_archive_path() const;
139 std::string get_archive_basename() const;
140 libdar::archive_options_read get_read_options(std::shared_ptr<html_web_user_interaction> dialog) const;
141
142 // common parameter to diff/create/restore/merge
143 const std::string & get_fs_root() const;
144
145 // extraction parameters
146 const libdar::archive_options_extract get_extraction_options() const;
147
148 // comparison parameters
149 const libdar::archive_options_diff get_comparison_options() const;
150
151 // testing options
152 const libdar::archive_options_test get_testing_options() const;
153
154 // create options
155 libdar::archive_options_create get_creating_options(std::shared_ptr<html_web_user_interaction> dialog) const;
156
157 // isolate options
158 const std::string & get_isolating_path() const { return isolate.get_archive_path(); };
159 const std::string & get_isolating_basename() const { return isolate.get_archive_basename(); };
160 libdar::archive_options_isolate get_isolating_options(std::shared_ptr<html_web_user_interaction> dialog) const;
161
162 // merge options
163 const std::string & get_merge_path() const { return merge.get_archive_path(); };
164 const std::string & get_merge_basename() const { return merge.get_archive_basename(); };
165 libdar::archive_options_merge get_merging_options(std::shared_ptr<html_web_user_interaction> dialog) const;
166
167 // repair options
168 std::string get_repairing_path() const { return repair.get_archive_path(); };
169 std::string get_repairing_basename() const { return repair.get_archive_basename(); };
170 libdar::archive_options_repair get_repairing_options(std::shared_ptr<html_web_user_interaction> dialog) const;
171
172 // listing or archive summary
173 bool do_we_list() const;
174
178 void set_session_name(const std::string & name) { session_name.set_value(name); act(changed_session_name); };
179
181 std::string get_session_name() const { return session_name.get_value(); };
182
184 void set_username(const std::string & username) { disco.set_username(username); };
185
187 void set_data_place(std::shared_ptr<html_fichier> & ref) { to_download = ref; };
188
189protected:
191 virtual std::string inherited_get_body_part(const chemin & path,
192 const request & req) override;
193
194 // inherited from body_builder
195 virtual void new_css_library_available() override;
196
197private:
198 enum
199 {
200 st_idle,
201 st_restore,
202 st_compare,
203 st_test,
204 st_list,
205 st_summary,
206 st_create,
207 st_isolate,
208 st_merge,
209 st_repair
210 } status;
211
212 std::string default_biblio_path;
213 std::shared_ptr<bibliotheque> biblio;
214
215 html_menu choice;
216 html_div right_pan;
217
219 html_archive_read archread;
220
221 // select zone
222 html_aiguille select;
223
224 // the different sub pages contained by "select" and shown depending on choice's value
225 html_div div_about;
226 html_div around_licensing;
227 html_static_url licensing;
228 html_image webdar_logo;
229 html_form_input session_name;
230 html_form_fieldset about_fs;
231 html_form about_form;
232 html_double_button show_demo;
233 html_demo demo;
234 //
235 html_archive_extract extract;
236 html_double_button go_extract;
237 //
238 html_archive_compare compare;
239 html_double_button go_compare;
240 //
241 html_derouleur test_params;
242
243 guichet guichet_test;
244 std::shared_ptr<html_options_test> test;
245 html_double_button go_test;
246 //
247 html_options_list list_or_summ;
248 html_double_button go_list;
249 //
250 html_archive_create create;
251 html_double_button go_create;
252 //
253 html_archive_isolate isolate;
254 html_double_button go_isolate;
255 //
256 html_archive_merge merge;
257 html_double_button go_merge;
258 //
259 html_archive_repair repair;
260 html_double_button go_repair;
261 //
262 std::unique_ptr<html_bibliotheque> h_biblio; // need a pointer as the bibliotheque object is needed to construct html_bibliotheque
263 //
264 html_yes_no_box close;
265 //
266 html_disconnect disco;
267
268 // the pointed to object is not adopted by this, but just filled with data (json bibliotheque config)
269 std::shared_ptr<html_fichier> to_download;
270
271 static const std::string css_class_text;
272
273 static const std::string menu_main;
274 static const std::string menu_restore;
275 static const std::string menu_compare;
276 static const std::string menu_test;
277 static const std::string menu_list;
278 static const std::string menu_create;
279 static const std::string menu_isolate;
280 static const std::string menu_merge;
281 static const std::string menu_repair;
282 static const std::string menu_biblio;
283 static const std::string menu_sessions;
284 static const std::string menu_close;
285
286 static const std::string css_class_logo;
287 static const std::string css_class_margin;
288 static const std::string css_class_choice;
289 static const std::string css_class_license;
290 static const std::string css_class_rightpan;
291 static const std::string css_class_float_clear;
292
293 static const std::string event_demo;
294};
295
296#endif
defines bibliotheque class
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
void act(const std::string &name)
trigger a given event
Definition: events.cpp:151
class guichet let one fetch config from a bibliotheque, save as or setup manually for a given compone...
Definition: guichet.hpp:92
class html_aiguille is a pure virtual class
Definition: html_aiguille.hpp:61
html component used to let the user provide parameters for an isolation operation
Definition: html_archive_compare.hpp:50
object providing html user interface component for the user to provide options to create a new archiv...
Definition: html_archive_create.hpp:50
html component used to let the user provide parameters for an isolation operation
Definition: html_archive_extract.hpp:48
html component used to let the user provide parameters for an isolation operation
Definition: html_archive_isolate.hpp:48
html component used to collect merging operation parameters from the user
Definition: html_archive_merge.hpp:50
class html_archive_read let user define the archive path, basename and option to read
Definition: html_archive_read.hpp:63
html component used to collect repairing operation parameters from the user
Definition: html_archive_repair.hpp:51
class html_demo show how webdar interacts with the browser
Definition: html_demo.hpp:73
class html_derouleur is a pure virtual class
Definition: html_derouleur.hpp:55
html component used for the user to define a has algorithm
Definition: html_disconnect.hpp:49
void set_username(const std::string &username)
set the username to display for the session ownership
Definition: html_disconnect.cpp:104
class html_div is the implementation of
Definition: html_div.hpp:46
html_button equivalent with changing path to trigger the button event
Definition: html_double_button.hpp:48
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_input implements HTML input feature
Definition: html_form_input.hpp:57
class html_form implements HTML form feature
Definition: html_form.hpp:51
html static component displaying an image from a given URL
Definition: html_image.hpp:44
class html_menu shows a menu and provides events to act on other objects
Definition: html_menu.hpp:51
html component for the user to provide parameters of libdar archive testing operation
Definition: html_options_list.hpp:47
html page root component
Definition: html_page.hpp:45
html component implementing the usual hyperlink component
Definition: html_static_url.hpp:45
html component for user to answer by yes or no to a provided question
Definition: html_yes_no_box.hpp:51
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
class saisie
Definition: saisie.hpp:106
std::string get_session_name() const
get the current session name
Definition: saisie.hpp:181
void set_session_name(const std::string &name)
Definition: saisie.hpp:178
virtual void new_css_library_available() override
inherited from body_builder
Definition: saisie.cpp:694
saisie()
constructor
Definition: saisie.cpp:86
static const std::string event_closing
available event for that class
Definition: saisie.hpp:109
void set_data_place(std::shared_ptr< html_fichier > &ref)
define the location where to drop data content before triggering the event_download
Definition: saisie.hpp:187
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: saisie.cpp:354
void set_username(const std::string &username)
define the username that the current session is owned by
Definition: saisie.hpp:184
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: saisie.cpp:421
defines the event class